Using always_filter on a PDT column

  • 20 December 2015
  • 3 replies

I’m currently using a derived table with templated filter, which has a default setting of limit to past 3 months via always_filter. It works nicely, though quite slow due to all the grouping involved in the derived table. What I’m trying to do is to create a persistent derived table so that everything is pre-grouped. Then I will just apply the filter after the PDT has been built.

Problem is, if I remove the following filter entry used by the templated filter (see 1st entry below) in the view definition I get a “always_filter: unknown filter field ‘view_name.filter_date’” message, even if I have a dimension field called filter_date (see 2nd entry). If I keep the filter entry, there’s no error but it ignores that filter (I guess the filter entry in the view is only used by templated_filters).

Am I doing something wrong or am I hitting a bug? Below shows the relevant lookml. Thanks.

On the view:

  - filter: filter_date
label: 'Date or Date Range'
type: date
convert_tz: false

- dimension: filter_date
type: time
timeframes: [date, week, month, year]
sql: ${TABLE}.filter_date
convert_tz: false

On the model:

- explore: view_name
filter_date: 3 months ago

3 replies

I think all you are missing is the “Dimension” reference of the Dimension Group “filter_date”

In your case, you want to use the dimension “filter_date_date”

Looker expose all “timeframes” as separate Dimensions. Here you can use “filter_date_date”, “filter_date_week”, …


Userlevel 2

Hey Johann,

Just to reiterate what Dominic said when you create a dimension like you have for filter_date with multiple timeframes, this actually creates all of those dimensions listed in the timeframes, so filter_date_date, filter_date_week, filter_date_month and filter_date_year. A bit more info on timeframe dimension groups here if you are interested. Have a good one!



Thanks and sorry for the late reply. Yes, defining it as a dimension group and using “filter_date_date” in the always_filter clause fixed it. Thanks again and happy new year!