Sales by Yesterday and WTD

  • 4 January 2019
  • 1 reply

How can I put different date filters on the same measure. Looking to show sales yesterday and sales week to date. All this data exists but how do I put that in the chart twice?

1 reply

Hey there @Ethan_Blitstein!

To do this most effectively, we’ll want to create a new filtered measure for each of the timeframes (i.e. yesterday and WTD). However, I remember from this article that you didn’t have permissions to create measures, so we’ll want to turn to custom fields. If your Looker admin has enabled the custom fields feature and given you access, you can add new custom dimensions and measures yourself. What we can do in this situation is use the matches_filter() function in a custom measure to essentially “copy” the base measure and then add a filter onto it with that function. So something along the lines of: matches_filter(${sales_field}, `yesterday`) and matches_filter(${sales_field}, `this week`) should do the trick. Also, to see a full list of the recognized Looker filter expressions that you could use in conjunction with the matches_filter() function, check out this doc! Feel free to hop on chat or visit if you get stuck and need to talk specifics!