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

Interactive Mode

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.

Filter using {CURRENT_USER} variable

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