Question

Date Filter in Multiple Explore

  • 22 February 2018
  • 8 replies
  • 1074 views

Date Filter in Multiple Explore:



I have a data filter say End Date in one of the explores. The condition for check will be if Table_date < = End Date.



My requirement is like in another explore I need to have it as Table_date > = End Date. Is it possible to have two different types of filter crtieria in separate explores. Since in both cases my where condition is like:



{% condition end_date %} TABLE_DT {% endcondition %}



The filter is placed in one single dashboard, and I have it as Before in the dropdown. Explore 1 takes as Before, but explore 2 also takes the same, is there any way I can change in query of explore 2?


8 replies

Hey @ayonsarkar- my first thought is to define this filter on each explore individually, but I assume that you want this filter to be a value you can apply at the dashboard level that can be changed and have each explore reflect that.



Since these explores are otherwise the same, we can approach this by setting up a parameter (link here) that has the value that should be applied to the two explores, and then using liquid (link here) to apply it differently on the two explores depending on the name of the explore.



Something like this:





{% if _explore._name == “explore_A” %}


table_date >= {% parameter end_date %}


{% elsif _explore._name == “explore_B” %}


table_date <= {% parameter end_date %}


{% else %}





{% endif %}



Thanks Jeremy…Can you please suggest where should I keep the below statements? Will it be in the individual explores?



{% if _explore._name == “explore_A” %}


table_date >= {% parameter end_date %}


{% elsif _explore._name == “explore_B” %}


table_date <= {% parameter end_date %}


{% else %}





{% endif %}

Hey @ayonsarkar this could be implemented in the WHERE clause of the SQL statement of a derived table as described in the doc on Templated Filters (link here) This doc also has a nice explaination of setting up and utilizing parameters.

thanks @jeremy.eckman. This worked individually for both the explores, Now if I try to add both the looks in the dashboard and have only the date parameter, how do I link the data filter in the dashboard with the one in the explore. I am trying to select and align it with the fields, it doesnot work as expected then.

any updates will be highly appreciated

Hey @ayonsarkar- Setting up the filter on the dashboard, we would point to the parameter for each look to be updated by this filter- in our example case this was end_date. If you require some more specific help with getting this working in your dashboard or model, please feel free to contact us at help.looker.com

thanks @jeremy.eckman

so far i did have found the answer to the question i had, but may i write you an email as well in case i will have questions? lots of thanks!

Reply