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

JC_U
New Member

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: 

Steps

** 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. 

Solved Solved
0 1 1,389
1 ACCEPTED SOLUTION

Hello!

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:

WHERE
{% 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: https://docs.looker.com/reference/field-params/filter

View solution in original post

1 REPLY 1

Hello!

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:

WHERE
{% 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: https://docs.looker.com/reference/field-params/filter

Top Labels in this Space