How to conditionally color table values based on whether they exist in a large “valid values” list?

Hi everyone,

I’m working on a Grafana dashboard (Grafana v11) where I am displaying tagging compliance for jobs. Each job has four tag fields:

  • product

  • project

  • harness

  • jobtype

    For each tag field, I have:

  1. A backend variable that returns all actual tag values found in the data (valid + invalid).

  2. A second custom variable that contains only the list of valid/approved tag values.
    (Each valid list has around 200–300 entries.)

My summary table shows one row per job with all four tags. What I want to do is:

  • If the tag value exists in the valid-values list → color the cell green

  • If the tag value does not exist in the valid-values list → color the cell red

Problem

I tried Value Mappings, but it requires manually adding each valid value, which is:

  • Time-consuming

  • Error-prone

  • Not scalable (because each valid list contains hundreds of values)

  • And I am not sure if Grafana has a practical limit for the number of value mappings.

Question

Is there a way in Grafana to:

  • Apply conditional cell color based on whether the value appears in a list variable, without manually mapping every allowed value?

  • Ideally using:

    • Overrides

    • Regex match

    • Transformations

    • Or a panel-level style rule

Data Source

Elastic / Lucene queries, displayed in a Table panel.

Looking for Guidance On:

  • Recommended Grafana pattern for this use case

  • Whether regex-based or variable-reference style coloring is supported

  • Any transformation or computed field approach others use for tag validation tables

Thanks,

Veena

Can you please post a sample data as json or inline csv here?

Thanks for the response. Here is a small sample dataset representing the table structure (values are anonymized):


cluster,product,project,harness,jobtype,user
farm_a,alpha,search,batch_x,compile,user1
farm_a,beta,analytics,batch_y,test,user2
farm_b,gamma,frontend,batch_z,run,user3
farm_b,invalid_prod,search,batch_x,compile,user4
farm_c,alpha,invalid_proj,batch_y,test,user5
farm_c,beta,analytics,invalid_harness,run,user6
farm_d,gamma,frontend,batch_z,invalid_jobtype,user7
farm_d,invalid_prod,invalid_proj,invalid_harness,invalid_jobtype,user8

Valid value list

Valid Products:

alpha, beta, gamma

Valid Projects:

search, analytics, frontend

Valid Harness:

batch_x, batch_y, batch_z

Valid JobTypes:

compile, test, run

In the real dataset, each valid list has ~200–300 entries.

A single row may have any combination of valid/invalid values.

I want to color code:

Green if value ∈ valid_list

  • Red if value ∉ valid_list

Without manually mapping each value.

Is there a scalable way to reference a variable or list in field overrides or transformations to apply conditional coloring?

Thanks again!

there is a new feature in grafana in preview mode you could take a look at, SQL Expression then use Config from query and Cell type as background color to use that field the color field.

I could not get it to work quiet exactly the way you want it, play with it.

Thank you for your response. I will try. Can I use SQL expression even though my data source is Elastic Search.

this should help answer

1 Like

Thanks again for taking time to answer my questions.