Knowledge Drop

Can I use/reference a `filter:` of type: number in a liquid statement?


Userlevel 5

Last tested: Jan 21, 2019
 

Yes, you can do this using the assign Liquid syntax. For example:

filter: filter_value_to_pass {

type: number

}

 

measure: my_measure {

type: sum

sql: ${TABLE}.field;;

html: {% assign var=_filters['filter_value_to_pass'] | plus: 0 %}

{% if value < var %}

<div style="color: blue">{{ value }}</div>

{% else %}

<div style="color: orange">{{ value }}</div>

{% endif %} ;;

}

Where | plus: 0 casts the var value from String to Integer. You could could also use | times: 1.



html: {% assign var=_filters['filter_value_to_pass'] | times: 1 %}

...

 

 

This content is subject to limited support.                

 


0 replies

Be the first to reply!

Reply