how to write this if statement with table value and parameter_value

I have the following two statements 

dimension: test1 {
type: number
sql: {% if ${event} = "ABC" and ${event1} = "ABC" %} then 1
{% else %} 0
{% endif %};;

dimension: test2 {
type: number
sql:{% if reservation_param._parameter_value == "123" and reservation_param._parameter_value1 == "123"%}  1
{% else %} 0
{% endif %};;

 

however, If I mix the parameter value with a table value, I keep getting an error. how can you mix parameter_value with table values?

 

dimension: test2 {
type: number
sql:{% if reservation_param._parameter_value == "123" and ${event} = "ABC" %}  1
{% else %} 0
{% endif %};;

 

 

BrianLewis_0-1726077200614.png

 

 

0 1 147
1 REPLY 1

You don't need to use the curly brace ${} syntax inside of a liquid statement. 

To reference a variable from another field, use the following syntax: view_name.field_name._value

So, in your example, it might look something like this:

dimension: test2 {
type: number
sql:{% if reservation_param._parameter_value == "123" and event._value == "ABC" %}  1
{% else %} 0
{% endif %};;

I omitted the view name because it seems like the event field is in the same view as test2, but if not, go ahead and add the view name.

Top Labels in this Space
Top Solution Authors