Changing Foreground Color using Expression property on a label

I have a label where the Text is bound to a numeric value (numberFormat({Tag/Path/Here},"#0.0")+" PSI") .

I am changing the foreground color from white to red if the value is below 12.

if ({Tag/Path/Here}< 12,
COLOR(255,0,0),COLOR(255,255,255))

I want to change the foreground color to red if the value is less than 12 and greater than16. Just adding in "... or > 16..."
doesn't seem to work. Any help is greatly appreciated!

You need two separate compares.

if({tag} < 12 || {tag} > 16, COLOR(255,0,0),COLOR(255,255,255))

Alternatively, you can use hex directly without calling COLOR()

if({tag} < 12 || {tag} > 16, "#FF0000","#FFFFFF")
2 Likes

To go one step further (if this is something you're going to want to do multiple times), you could embed the label in a view, add one property, and change the style based on that property. Then you can do more complex things in your style.

1 Like

I am learning as I go and this Ignition Forum is invaluable!

I ended up using || instead of OR

Thanks you!

Syntax error on my part. Hard to keep it straight all the time between expressions and scripts when I'm just writing here on the forum.