# Color table cell depending on value in another column

**URL:** <https://forum.inductiveautomation.com/t/color-table-cell-depending-on-value-in-another-column/7301>\
**Category:** Ignition\
**Created:** [September 23, 2013, 2:55pm UTC](https://forum.inductiveautomation.com/t/color-table-cell-depending-on-value-in-another-column/7301 "2013-09-23T14:55:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brett\_Yeomans](https://avatars.discourse-cdn.com/v4/letter/b/35a633/32.png) [@Brett\_Yeomans](https://forum.inductiveautomation.com/u/Brett_Yeomans)\
**Post date:** [September 23, 2013, 2:55pm UTC](https://forum.inductiveautomation.com/t/color-table-cell-depending-on-value-in-another-column/7301/1 "2013-09-23T14:55:45Z")

</div>

Is it possible on a table to have the cell color decided by a value in a different column?  
I’m thinking of the ‘getBackgroundAt’ function but this uses the value in the cell to be altered?  
Is there any way of using this:

self.getPropertyValue(‘propertyName’)

I have tried various things like below and failed

`if col ==11 and value > self.getPropertyValue(data[selectedRow,0) :
		return Color.red`

(my SQL result has a ‘target’ value column and an ‘actual’, I want the target value to determine the ‘actual’ background color)

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [September 23, 2013, 3:26pm UTC](https://forum.inductiveautomation.com/t/color-table-cell-depending-on-value-in-another-column/7301/2 "2013-09-23T15:26:39Z")

</div>

I think you should use the Table Customizer for this. In Ignition Designer, right-click on the Table.

If you have to have a programmatic way of changing it then you can add your own row (or update an existing one) in the table.columnAttributesData property:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/c/8c52ae4d6ee8d97c1e49ce0356890bbf7290fd80.jpeg)

---

<div class="post-metadata">

**Author:** ![Brett\_Yeomans](https://avatars.discourse-cdn.com/v4/letter/b/35a633/32.png) [@Brett\_Yeomans](https://forum.inductiveautomation.com/u/Brett_Yeomans)\
**Post date:** [September 24, 2013, 7:06am UTC](https://forum.inductiveautomation.com/t/color-table-cell-depending-on-value-in-another-column/7301/3 "2013-09-24T07:06:29Z")

</div>

Thanks adamaustin,  
Trouble is a I have 5 targets/actuals per row and therefore would have liked to have individual colors per cell. Seeing the topic regarding the reference to the ‘self’ property I thought maybe this could be possible. ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

Is there anyway of having a dynamic value after the comparison  
i.e.

```auto
if col ==2 and value < system.tag.read("Test area - delete whenever/test") :
```

Or is this just not possible

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [September 24, 2013, 4:01pm UTC](https://forum.inductiveautomation.com/t/color-table-cell-depending-on-value-in-another-column/7301/4 "2013-09-24T16:01:17Z")

</div>

Actually, in 7.6 we added Extension Function (like getBackgroundAt) just so you can do that. They are in the Component Scripting under the Event Handlers.

---

<div class="post-metadata">

**Author:** ![Brett\_Yeomans](https://avatars.discourse-cdn.com/v4/letter/b/35a633/32.png) [@Brett\_Yeomans](https://forum.inductiveautomation.com/u/Brett_Yeomans)\
**Post date:** [September 24, 2013, 6:44pm UTC](https://forum.inductiveautomation.com/t/color-table-cell-depending-on-value-in-another-column/7301/5 "2013-09-24T18:44:05Z")

</div>

But can this function (getBackgroundAt) reference a value that is not hard coded i.e. preferably another column value or a tag?

In the original question I had noticed someone using the ‘self.getProperty’ and wanted to know if this is a function to reference the table data in a column other than the one to be colored.

or…

Can a tag be used after the comparison

In short, can a value OTHER THAN the value in the cell to be colored be used as the decision on what color is chosen when using the getBackgroundAt ?

If so any chance of an example as when I tried things like system.tag.read(“blah…”) it didn’t work.  
 ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [September 24, 2013, 7:22pm UTC](https://forum.inductiveautomation.com/t/color-table-cell-depending-on-value-in-another-column/7301/6 "2013-09-24T19:22:28Z")

</div>

Yeah, if you check out the extension function, it has some documentation in it. Namely, you get the row and column of the dataset that the cell in question refers to. With that, you can get another value using something like this:`from java.awt import Color
if self.data.getValueAt(row,0) > 15:
	return Color.green`

---

<div class="post-metadata">

**Author:** ![Brett\_Yeomans](https://avatars.discourse-cdn.com/v4/letter/b/35a633/32.png) [@Brett\_Yeomans](https://forum.inductiveautomation.com/u/Brett_Yeomans)\
**Post date:** [September 25, 2013, 7:31am UTC](https://forum.inductiveautomation.com/t/color-table-cell-depending-on-value-in-another-column/7301/7 "2013-09-25T07:31:06Z")

</div>

Perfect, thanks.

![:thumb_right:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/2026e28c0c425034352c1b75807edf956adc75f4.gif ":thumb\_right:")
