View the original community article here
Last tested: Apr 10, 2020
Nope, we'll need to use a parameter if we want to add user inputs to a conditional statement
Scenario:
We have a yesno dimension that users are filtering on. We want to be able to pull in that value that users select to display a measure based off the condition.
LookML Definition:
Explore View (What users see):
Generated SQL:
Ideal Outcome:
Based off the set up, ideally what would happen here is if our user changes the filter to "No" then we'll display 2 in the measure. However, what we'll see is if we update the "Yes/No" filter to "No", it will add it to the WHERE clause and the SELECT statement defined in the measure will remain the same. (Therefore justifies that the yes/no condition isn't being checked)
Why it doesn't work:
In order for Looker to grab the user selected Filter value, we need to run the query in order to know what the user select (yes or no). However, there's no mechanism within Looker to run the query to grab that value, then input the selection into another query to update the measure to display the proper number. In the case of this example above, what happens is if a user selects "No" then we'll run the query and see it added to the WHERE clause, but the SELECT statement doesn't update and still selects and returns 1.
This content is subject to limited support.