I am trying to write a section of conditional logic in the sql: section of a derived_table using a parameter. My strong preference is to use a string parameter to avoid using arbitrary numbers to control the logic.
This is the non-working version. No matter what value of the parameter is selected, the Liquid always resolves to the ‘else’ case. I have tried every different variant of reference a parameter that I have found online.
where status = status_lookup.id and
{% if period_week_filter._parameter_value == 'before_next' %}
week_index < 6
{% else %}
week_index < 2
{% endif %};;
the parameter definition is:
parameter:period_week_filter {
type: string
allowed_value: {
value: "before_next"
}
allowed_value: {
value: "before_last"
}
default_value: "before_next"
}
The same code works fine, however, if I switch over to a number type parameter.
where status = status_lookup.id and
{% if period_week_filter._parameter_value == '1' %}
week_index < 6
{% else %}
week_index < 2
{% endif %};;
the corresponding parameter definition is:
parameter:period_week_filter {
type: number
allowed_value: {
label: "before_next"
value: "1"
}
allowed_value: {
label: "before_last"
value: "2"
}
default_value: "before_next"
}
Please help - Thanks!