Can I use the value from the dashboard filter in my sql derived table's WHERE statement?

  • 7 June 2022
  • 1 reply

I have a dashboard with an organization filter on it and I am wondering based on the organization that users select, whether I can write something like this in my sql-derived table. Basically, each organization has a different max date and I want to only output the data that is from that max_date like so: 



** Dashboard user selects Organization A on the dashboard ** 


My sql-derived table: 

WHERE date(run_time) = (select max(date) from table where organization_name = {{ _filters['viewname.value'] }}) 

..where {{ _filters['viewname.value'] }})  equals Organization A, the org that the user selected in the dashboard filter.

^ the above is obviously not working but I hope it shows what I’m trying to do. 


Best answer by Jimmy_Westman 10 June 2022, 15:06

View original

This topic has been closed for comments

1 reply


Yes, this can be done. First you have to create a filter in the view file. This filter will appear in the explore just as any other dimension or measure. You can then apply a dashboard filter to this filter in the view.

By using this syntax:

{% condition order_region %} order.region {% endcondition %}
you can then pass the value selected in the filter into the SQL of the derived table.


You can read about it here: