How to set style states based on part of a text variable

I’m working on creating a tile to show weather alerts. I’m hoping to set the tile style based on one of three states: 0: No alerts, 1: Air quality alert (minor), 2: all other alerts (severe weather; major). To do it I was hoping to use state style operator “contains,” but it seems even though the field is a text field, the available operators are numeric (=, >, <, etc.). I can use = and != for states 0 and 2, but not for state 1 because there will be other text besides “air quality,” so the second rule is never true.
image

I thought maybe I could write a rule to set a second variable to a numeric value of 0, 1, or 2 and trigger the style based on that, but I found even in the Rule Editor if conditions, the available operators are only Is, Is Not, and Has Stayed. So my question is, is there a way to set the style or variable value based on the text content of a variable, using a partial match (contains) operator?

You can use Rules to trigger off a change to that property and then use expressions with functions like ‘contains’ and set a Variable. Then you can add a Variable tile to your dashboard and set styles based on its value.

2 Likes

Thank you! That worked!

1 Like