Liquid Parameters - Output inside IF block

Finally got some time to spend on Liquid and I have this use case, mostly to reduce the SQL.

Right now I have this

dimension: test {
sql: CASE
WHEN {% parameter test %} = 'Day'
-- Something
WHEN {% paramter test %} = 'Week'
-- Something else
ELSE NULL
END ;;
}

But I would like to do this: 

dimension: test {
sql: {% if test._parameter_value == 'Day' %}
1 = 1
{% else %}
CASE
WHEN {% paramter test %} = 'Week'
-- Something else
ELSE NULL
END ;;
{% endif %}
}

The problem is that {% paramter test %} value is not inserted if it’s within IF block. Just wondering if it’s even possible?

0 1 135
1 REPLY 1

Ahh rookie mistake   == “’Day’”

When you use a parameter with type: string, the parameter_name._parameter_value Liquid variable requires that you enclose the values of the parameter with both single and double quotes. This is so that the single quotes are transmitted to the SQL, identifying the value as a string value. See the following example:

Top Labels in this Space
Top Solution Authors