Question

Always_filter for yesno dimensions results in "matches (advanced)" filters


Userlevel 3

I’m setting up an Explore with an always_filter parameter to remove rows with test data. The dimension is type yesno, and the default value for the Explore is “no”.


So my LookML looks like this–


In the user View file:


dimension: is_test_data {
type: yesno
sql: ${TABLE}.is_test_data ;;
}

In the Explore file:


always_filter: {
filters: {
field: user.is_test_data
value: "no"
}
}

I would expect to see a straightforward yesno filter in the Explore by default like this:



But in Looker 4.14, I get an advanced filter, like this:



Is there a way I can get the default filter to look like the first screenshot?


Both are functionally equivalent, of course, but the first version of it seems more user-friendly. This filter will be the default of our most popular Explores so I’d like to make sure that I’m doing this correctly.


(Also, if there’s an alternative, better approach to what I’m doing than always_filter, I’d love to hear that, too.)


Thanks!


10 replies

Userlevel 3

@gregono do you need the user to be able to change the filter? If not, you could consider the sql_always_where parameter instead of always_filter. Maybe that would bypass this issue altogether.

Userlevel 3

That’s a nice idea, but unfortunately users would like to include test data in their reports, so I’d like to keep the filter changeable. Thanks.

Userlevel 1

Hey @gregono try changing your code to an upper case No like this:


 always_filter: {
filters: {
field: user.is_test_data
value: "No"
}
}

Using uppercase should trigger looker to default to the Yes/No filter UI rather than matches (advanced)

Userlevel 3

That worked. Thanks!

@jessica This hack is LIFECHANGING! Thank you! (And thanks to @gregono for raising the topic.)

@jessica Thanks so much! FYI, in the filter expressions documentation, under Boolean, the directions appear to be to use all lowercase to achieve this. Perhaps this should be updated? https://docs.looker.com/reference/filter-expressions#boolean

@jessica

A quick update to the docs to fix the capitalization would definitely be helpful. I spent 20 min reading through docs trying to figure out how to fix this issue until I found this thread, which basically explains that the docs are incorrect.

Userlevel 4

Hi @jyau I’ve made a request to add this to our documentation so there’s no confusion going forward. Sorry you had to spend so long fiddling about to get it to work. Hopefully all is well now?

That’s great. Yes, a quick search and replace solved this for us once we knew the resolution.

Userlevel 3

Sorry for the confusion, this has been updated at https://docs.looker.com/reference/filter-expressions#boolean

Reply