# Changing text colour based on tag value

**URL:** <https://forum.inductiveautomation.com/t/changing-text-colour-based-on-tag-value/25958>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [June 19, 2019, 7:43pm UTC](https://forum.inductiveautomation.com/t/changing-text-colour-based-on-tag-value/25958 "2019-06-19T19:43:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andyg](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@andyg](https://forum.inductiveautomation.com/u/andyg)\
**Post date:** [June 19, 2019, 7:43pm UTC](https://forum.inductiveautomation.com/t/changing-text-colour-based-on-tag-value/25958/1 "2019-06-19T19:43:37Z")

</div>

Hi,  
I am trying to change the text colour of a numeric label, based on whether its tag value is greater than or less than another tags value. I’m not sure if this can be done with scripting or within the style customizer, but i am having a hard time figuring it out. Any suggestions?  
Thanks!

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 19, 2019, 7:56pm UTC](https://forum.inductiveautomation.com/t/changing-text-colour-based-on-tag-value/25958/2 "2019-06-19T19:56:16Z")

</div>

Create a custom property on the Numeric Label component with a Type Color.

You will then be able to bind that to an expression so that it is the color you want based on the values of your tags.

something like this:

```auto
if(componentTagValue > testTagValue,color(0,0,255),color(255,0,0))

```

Then bind the backgroundColor property of the numeric label to the custom property.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 19, 2019, 8:10pm UTC](https://forum.inductiveautomation.com/t/changing-text-colour-based-on-tag-value/25958/3 "2019-06-19T20:10:31Z")

</div>

I agree with the custom property, but bind it to the comparison:

`{Root Container.Numeric Label.value} > {[default]path/to/test/tag}`

Then the style Customizer could look something like this:

 ![2019-06-19_16-08-59](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/cfc4288b7bcffa7f656680b22eee7095180ff9d8.jpeg)  
The Style Customizer will also give you greater flexibility in how the component looks.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 19, 2019, 8:18pm UTC](https://forum.inductiveautomation.com/t/changing-text-colour-based-on-tag-value/25958/4 "2019-06-19T20:18:12Z")

</div>

Honestly, didn’t think about that.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 19, 2019, 8:20pm UTC](https://forum.inductiveautomation.com/t/changing-text-colour-based-on-tag-value/25958/5 "2019-06-19T20:20:52Z")

</div>

No worries, my friend. Just shows how many cats can be skinned to do the same thing. 🙂

---

<div class="post-metadata">

**Author:** ![andyg](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@andyg](https://forum.inductiveautomation.com/u/andyg)\
**Post date:** [June 19, 2019, 8:44pm UTC](https://forum.inductiveautomation.com/t/changing-text-colour-based-on-tag-value/25958/6 "2019-06-19T20:44:52Z")

</div>

Thank you very much! This helped a lot!

---

<div class="post-metadata">

**Author:** ![alexm](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@alexm](https://forum.inductiveautomation.com/u/alexm)\
**Post date:** [March 26, 2020, 2:14pm UTC](https://forum.inductiveautomation.com/t/changing-text-colour-based-on-tag-value/25958/7 "2020-03-26T14:14:33Z")

</div>

Hi,

I am using perspective and I would like a label to turn Red colour from white when a value is greater than 5(reading it from PLC). At the moment I have created a property on the params that I would bind to the tag value I am interested. So inside the component I have the red label attached and I am stuck with the expression which is: if({view.params.FailCount}\>5,true,false) , but I get this error Error\_ExpressionEval. Any ideas to fix this?

Kind regards
