Where statement on specific date?


Hi all, I have a query similar to this:

select * from my_table
where date='hardcoded_date'

I want the user be able to dynamically change the ‘hardcoded_date’ date by entering a filter but I’m not sure how to go about doing this.


(Lauren Boltz) #2

Hi @_Andrew,

Thank you for your post! We can apply filters directly in the UI of an Explore, Look, or Dashboard to essentially apply a WHERE clause to limit the resulting data.

This document gives an overview of how to go about applying filters in an Explore, along with the various filter types:

  • Basic - The most common filter. Looker populates appropriate drop-down lists, calendar widgets, and text fields you can use to put in your restriction.

  • Advance Matches - This filter option allows us to specify a filter with a more advanced condition for a field, such as more intricate string searches, or a date range.

  • Custom - Custom filters allow us to apply more detailed business logic to conditions - especially when you need to combine AND and OR logic together, or want to use Looker functions listed here to achieve more nuanced results.

In this case, we can use a basic filter in an Explore - filtering on the desired date dimension to set the WHERE date = hardcoded_date specified by the end user. We can do this by selecting the dimension to filter by, and setting the condition to On the Day:

This returns results for the date specified. As you can see above, I selected the date 10-9-2018, which returns the results that meet that condition in the results table.

In addition to Explores and Looks, we can also apply filters to Dashboards.

Any filters applied to an Explore that is saved as a Look, or added to a Dashboard as a tile, will apply to the Look or Dashboard tile unless otherwise edited. Existing Explore filters can be overridden by a Dashboard filter, as specified in the documentation listed above.

If you have any further questions about filtering and limiting information in Looker, please don’t hesitate to reach out to Support at support@looker.com !


Looker Support