# Excel-like conditional formatting in a table?

**URL:** <https://forum.inductiveautomation.com/t/excel-like-conditional-formatting-in-a-table/3056>\
**Category:** Ignition\
**Created:** [July 1, 2011, 1:14pm UTC](https://forum.inductiveautomation.com/t/excel-like-conditional-formatting-in-a-table/3056 "2011-07-01T13:14:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamstagnaro](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@adamstagnaro](https://forum.inductiveautomation.com/u/adamstagnaro)\
**Post date:** [July 1, 2011, 1:14pm UTC](https://forum.inductiveautomation.com/t/excel-like-conditional-formatting-in-a-table/3056/1 "2011-07-01T13:14:38Z")

</div>

(just sent this to the support email, and realized it was more appropriate for the forum)

Is there a way to do Excel-like conditional formatting in a SQL table? I have several columns that I’d like to do color mapping in, but not on the whole row, only on that cell within the formatted column.

Thanks.

Adam S

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [July 1, 2011, 1:54pm UTC](https://forum.inductiveautomation.com/t/excel-like-conditional-formatting-in-a-table/3056/2 "2011-07-01T13:54:16Z")

</div>

You can HTML format the cell by prepending"" to the cell text and using HTML to color the font, background, etc. You would need to populate the data with an SQL query that contains the conditional logic.

---

<div class="post-metadata">

**Author:** ![adamstagnaro](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@adamstagnaro](https://forum.inductiveautomation.com/u/adamstagnaro)\
**Post date:** [July 1, 2011, 2:15pm UTC](https://forum.inductiveautomation.com/t/excel-like-conditional-formatting-in-a-table/3056/3 "2011-07-01T14:15:22Z")

</div>

I apologize… you’re speaking a different language than I speak (I’m a MechEng pretending to be a programmer 😕 ). Could you please give an example?

Also, I read that 7.2.6 has something called “column foreground color”… I am on 7.2.4 so I’m not sure what this. Would this be anything like what I was asking about?

Thank you.

Adam S

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [July 1, 2011, 3:13pm UTC](https://forum.inductiveautomation.com/t/excel-like-conditional-formatting-in-a-table/3056/4 "2011-07-01T15:13:55Z")

</div>

As of Ignition 7.2.6 (if you are at an older version please upgrade for this feature) the table now supports background cell mapping to change the color of individual cells based on another column in the table. The mapping is configured in the table customizer. Let’s say you have the following query:

SELECT id, name, value FROM table

and you want to change the background of the value column like so:

value \<= 0 - red  
value \> 0 and value \<= 50 - yellow  
value \> 50 - green

You first need to add another column to your SQL query that returns an integer state like so:

```auto
SELECT id, name, value, CASE WHEN value <= 0 THEN 0 WHEN value > 0 AND value <= 50 THEN 1 ELSE 2 END AS valueState FROM table
```

Once you do that you can set the background color mapping for the value column to 0 = red, 1 = yellow and 2 = green. You just need to set the background color column to valueState. Let me know if you have any questions.
