Conditional formatting in the table panel

Dear Grafana Team,

I would like to request a feature for the Grafana Table Panel.

Currently, conditional formatting (like coloring a cell background) can only be applied based on the value of the same field.
It is not possible to compare two fields (example: if Actual Sales < Target Sales) and then apply coloring based on that.
Feature Request:
Enable conditional formatting where we can compare two fields in a table panel, and apply background color or text color based on that comparison.

Example Use Case:

Show Actual Sales and Target Sales columns.

If Actual Sales is less than Target Sales, color the Actual Sales cell red.

Otherwise, keep it normal or green.

This feature would be very helpful for many business dashboards where targets vs actuals need to be visualized cleanly without extra calculated fields.

Thank you for considering this!

1 Like

Hi,

If you need it now, you can achieve it by:

  1. Calculating the difference by hand between those two fields and then applying some operation that will return special value from negative numbers (like ln will return Nan).

    You’ll be left with two more columns but we can hide them later.
  2. Go to value mapping and create a value mapping like this:

    Since ln can be calculated for all non-negative numbers, you’ll have either some number or the Nan, which will be colored in red.
  3. For coloring, use this option:
  4. To hide the additional fields, use such override

I realise that this is far from ideal, but I think it’s a nice workaround.

2 Likes

Here’s what I don’t understand about value maps: when you create a value mapping, how do you know which column in your dataset the value came from? I have a column that is a flag in my dataset, a 0 or 1. I would like to change the text color in another field (the flag is hidden from view) based upon this flag.

Is it possible to do this? Would I use a value map to accomplish this?
Thank you

welcome to forum @davidmbuttrick

what is your datasource? mysql?

AFAIK the value mapping applies to each value separately - not a certain column (unless specified in field overrides, then it applies only to those specific column). To help you in your specific case, I think we’d need some example data (e.g. some screen or json or something like that) to experiment a bit.