Variable Types

Chartio provides convenient variables you can use to dynamically update values in your dashboards and charts:

Relative Date Variables

Chartio offers built-in date variables that can be used across the application. They each resolve to a single date string, so you can use them anywhere you would otherwise enter a date value. For example, you can:

  • set default dates for dashboard date Controls, such as a Calendar or a Date Slider
  • use in custom formulas in the Pipeline
  • use in SQL Mode
  • use in Visual Mode filters

Relative Date Variables follow the Time Zone your dashboard uses.

View examples

Available Variables

  • {TODAY}
  • {CURRENT_ISO_WEEK.START} and {CURRENT_ISO_WEEK.END}
  • {CURRENT_QUARTER.START} and {CURRENT_QUARTER.END}
  • {CURRENT_MONTH.START} and {CURRENT_MONTH.END}
  • {CURRENT_CALENDAR_YEAR.START} and {CURRENT_CALENDAR_YEAR.END}

Functions

You can perform functions on datetime variables that will allow you to customize the date returned to fit your needs. To learn more, check out our Datetime Functions documentation.


Current User Variable

Catering dashboards to a specific viewer is possible with the use of the {CURRENT_USER} variable. The {CURRENT_USER} variable stores the email of the user currently viewing a dashboard. Use this value in your queries to build dashboards and charts that can be filtered based on who is currently viewing the dashboard. You can use this variable as you would any other Relative Date Variable as it’s built-in to Chartio and can be used across the application.

Charts

Visual Mode

In the Visual SQL interface
Filter using {CURRENT_USER} variable in Visual SQL

When using the {CURRENT_USER} variable to filter a chart, select the column or field you’d like to use as a filter, choose = for the filter operator, and enter {CURRENT_USER} as the value, making sure to wrap the variable name in curly brackets.

In the Data Explorer interface
Filter using {CURRENT_USER} variable in Data Explorer

When using the {CURRENT_USER} variable to filter a chart, select the column or field you’d like to use as a filter and set it equal to a Custom Value. In the Custom Value field, type in {CURRENT_USER}, making sure to wrap the variable name in curly brackets.

SQL Mode

Use the {CURRENT_USER} variable like you would any other dashboard variable by simply typing in {CURRENT_USER} within your queries and using it with any column or field you wish to filter.

For example, in the query below, we’re filtering our results using our “user_email” column:

select count(distinct "tablename"."users") as "Count of users
from "public"."tablename" as "tablename"
where (("tablename"."user_email" = {CURRENT_USER}))
limit 10000;

You can also select the current user’s email by using {CURRENT_USER} in the SELECT clause of your query. It can be used as-is in your chart or parts can be extracted to further use as needed.

select {CURRENT_USER} as "Current User";

Dashboard

Use the {CURRENT_USER} variable as a global variable to filter your entire dashboard by adding it to all charts on your dashboard. The variable itself is already available to use like Relative Date Variables, so you don’t need to create it like any of the other Dashboard Controls. If you want to display the current user, you can add a Text Element and set it equal to the value of the {CURRENT_USER} variable, as seen in the example below:

Current User variable in a Text Element