Conditional liquid filter - string matching not exact

  • 28 January 2021
  • 1 reply

Hi - I want the user to be able to input a value in a filter in a dashboard and then apply that value within the SQL for the derived table. The problem is I need to use a LIKE statement not an exact match.

I found this example: which is a where statement with an exact match on a user’s input, I just want to convert this so the field contains the user’s input.

Essentially I am trying wanting to do something like this:

, cASE WHEN test_name LIKE ‘%concat({user_input}, ‘-control’)%’ THEN 'Control'
             WHEN test_name LIKE ‘%concat({user_input}, ‘-expa’)%’ THEN 'ExpA'
             ELSE 'None' end as test_variation

This topic has been closed for comments

1 reply

For inputting specific user inputted values directly into sql statements, we would likely want to use a lookml parameter field. Then we could refer to the value inputted by the user with {% parameter parameter_name %} in our sql statement. A bit more info with an example here!