Excel-like conditional formatting in a table?

(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.


Adam S

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.

I apologize… you’re speaking a different language than I speak (I’m a MechEng pretending to be a programmer :confused: ). 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

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:

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.