# Color-coding labels in a table based on pre-defined threshold values

**URL:** <https://forum.inductiveautomation.com/t/color-coding-labels-in-a-table-based-on-pre-defined-threshold-values/52082>\
**Category:** Ignition\
**Created:** [October 18, 2021, 9:27pm UTC](https://forum.inductiveautomation.com/t/color-coding-labels-in-a-table-based-on-pre-defined-threshold-values/52082 "2021-10-18T21:27:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![user37](https://avatars.discourse-cdn.com/v4/letter/u/e19b73/32.png) [@user37](https://forum.inductiveautomation.com/u/user37)\
**Post date:** [October 18, 2021, 9:27pm UTC](https://forum.inductiveautomation.com/t/color-coding-labels-in-a-table-based-on-pre-defined-threshold-values/52082/1 "2021-10-18T21:27:29Z")

</div>

My students have created a table in Ignition. In this table it has values for the percentage full a specific tank is. I would like for them to color-code the values based on pre-defined values. For example, if a tank is \< 25% but \> 10% full, I would like the text/label (or, preferably, the background of the text/label) to be color-coded yellow as a warning, and if it were \<10% full to be color-coded red.

Is that doable? If so, how?

Thanks!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 18, 2021, 9:35pm UTC](https://forum.inductiveautomation.com/t/color-coding-labels-in-a-table-based-on-pre-defined-threshold-values/52082/2 "2021-10-18T21:35:39Z")

</div>

First question: Vision, or Perspective?

---

<div class="post-metadata">

**Author:** ![user37](https://avatars.discourse-cdn.com/v4/letter/u/e19b73/32.png) [@user37](https://forum.inductiveautomation.com/u/user37)\
**Post date:** [October 18, 2021, 9:37pm UTC](https://forum.inductiveautomation.com/t/color-coding-labels-in-a-table-based-on-pre-defined-threshold-values/52082/3 "2021-10-18T21:37:47Z")

</div>

It was created in Perspective.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 18, 2021, 9:43pm UTC](https://forum.inductiveautomation.com/t/color-coding-labels-in-a-table-based-on-pre-defined-threshold-values/52082/4 "2021-10-18T21:43:42Z")

</div>

Okay, so within a table you must define styles as additional config on each data row. What that’s probably going to mean is a script transform on your incoming data (wherever it comes from) that adds style information to each row appropriate for how it should be rendered. Take a look at the way the Table component is renderer when you first create one:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/09f284e6470d518c69adbd25eabd3dcae47d66fc.png)

Your binding or whatever data source on `table.props.data` needs to add that extra style information.

---

<div class="post-metadata">

**Author:** ![user37](https://avatars.discourse-cdn.com/v4/letter/u/e19b73/32.png) [@user37](https://forum.inductiveautomation.com/u/user37)\
**Post date:** [October 18, 2021, 9:55pm UTC](https://forum.inductiveautomation.com/t/color-coding-labels-in-a-table-based-on-pre-defined-threshold-values/52082/5 "2021-10-18T21:55:34Z")

</div>

The table data is coming in as a query bind. Not sure how to do a script transform that can add style information to each row’s data. There is a “tank percentage full” field from the DB table that the color will be based off. For now, I have set the data column to be a progress bar so there’s at least some sort of visual. But that color is the same regardless of the percentage.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 18, 2021, 10:08pm UTC](https://forum.inductiveautomation.com/t/color-coding-labels-in-a-table-based-on-pre-defined-threshold-values/52082/6 "2021-10-18T22:08:40Z")

</div>

There's a bunch of threads about this same problem on the forum, but here's one example:

> [@Changing colour of row based off value in cell in perspective table](https://forum.inductiveautomation.com/t/changing-colour-of-row-based-off-value-in-cell-in-perspective-table/43587):
>
> Hi, I just want to change the colour of the rows in my table based off the values on one of the cells. I am unsure on how to go about this in perspective, any help is welcome.

---

<div class="post-metadata">

**Author:** ![user37](https://avatars.discourse-cdn.com/v4/letter/u/e19b73/32.png) [@user37](https://forum.inductiveautomation.com/u/user37)\
**Post date:** [October 19, 2021, 1:15pm UTC](https://forum.inductiveautomation.com/t/color-coding-labels-in-a-table-based-on-pre-defined-threshold-values/52082/7 "2021-10-19T13:15:39Z")

</div>

Thanks, you have been very helpful!

Pat
