How to evaluate when a templated filter is not filtered i.e. 1=1

Knowledge Drop

Author: Josh Lowin

Last tested: Feb 25, 2021
 

The Problem

If no value is selected when using a templated filter Looker will default to pass 1=1 in sql, so how can we evaluate this case to get a particular desired output?

A Solution

We can cast the liquid condition to a string and check if it evaluates to the string "1=1" and base the condition on that.

IF(CAST({% condition filter_name %} sql_or_lookml_reference {% endcondition %} AS STRING) = "1=1",no_condition_output,{% condition filter_name %} sql_or_lookml_reference {% endcondition %})

This content is subject to limited support.                

Version history
Last update:
‎06-14-2021 05:54 PM
Updated by: