How to use variables for better filtering in Directus Insights

Roger Stringer
June 04, 2023
2 min read

Directus' Insights panels are a handy feature of the data studio, creating charts to see your data when you want to, but adding filters such as daterange and groupBy make it even more flexible.

1. The Date Range

Create a global variable called daterange, this will be a drop down as shown in the image below.

For each value, give a relative date so for example Past 1 Week, save the value as 1 week, for example:

2. The Group By

Next, create a global variable called groupBy, this will be a drop down as shown in the image below.

3. Put It All Together

Create a time series chart, for example,

For the Group Precision field, use the raw value editor and enter {{ groupBy }}, then for the Date Range field, use the raw value editor and enter {{ daterange }}.

Now if you change the values in these dropdowns, the charts will update automatically.

You can use these variable for any other charts that use

Do you like my content?

Sponsor Me On Github