Knowledge Drop

Can we reference a yesno dimension in a condition statement using liquid?

  • 7 July 2021
  • 0 replies
  • 54 views

Userlevel 4

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:
Screen Shot 2020-04-10 at 3.42.29 PM.png

Explore View (What users see):
 

Screen Shot 2020-04-10 at 3.56.30 PM.png

Generated SQL:

Screen Shot 2020-04-10 at 3.56.37 PM.png

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.                

 

 


0 replies

Be the first to reply!

Reply