In Grafana 12.3.1 on Windows 11, I am looking to apply a cell-level color conditional formatting in a matrix table where the displayed value is the amount of a month and the color is based on the delta between the month’s value and its previous month’s value that is included in the query but not displayed in the table. Sample data is arranged through this query, after which it is transformed using “Grouping to matrix” [Column: Month, Row: Product, Cell value: Total Cost]:
WITH fake_monthly_costs AS (
SELECT *
FROM (VALUES
('Product A', DATE '2026-01-01', 100.00),
('Product A', DATE '2026-02-01', 120.00),
('Product A', DATE '2026-03-01', 90.00),
('Product A', DATE '2026-04-01', 95.00),
('Product A', DATE '2026-05-01', 80.00),
('Product A', DATE '2026-06-01', 130.00),
('Product B', DATE '2026-01-01', 500.00),
('Product B', DATE '2026-02-01', 450.00),
('Product B', DATE '2026-03-01', 470.00),
('Product B', DATE '2026-04-01', 470.00),
('Product B', DATE '2026-05-01', 430.00),
('Product B', DATE '2026-06-01', 460.00),
('Product C', DATE '2026-01-01', 1000.00),
('Product C', DATE '2026-02-01', 1100.00),
('Product C', DATE '2026-03-01', 1050.00),
('Product C', DATE '2026-04-01', 980.00),
('Product C', DATE '2026-05-01', 980.00),
('Product C', DATE '2026-06-01', 900.00)
) AS t(product, month_start, total_cost)
),
with_delta AS (
SELECT
product,
month_start,
total_cost,
total_cost
- LAG(total_cost) OVER (
PARTITION BY product
ORDER BY month_start
) AS mom_delta
FROM fake_monthly_costs
)
SELECT
product AS "Product",
to_char(month_start, 'FMMonth, YYYY') AS "Month",
total_cost AS "Total Cost",
mom_delta AS "MoM Delta",
month_start AS "Month Sort"
FROM with_delta
ORDER BY
product,
month_start;
I used the “Add field override” feature to configure thresholds in a single column (May, 2026) to highlight cells in red if value (my initial assumption is the MoM Delta value) is >0 and green if <0
However, the values that is being used for threshold highlighting is the one that is displayed in the table (Total Cost value)
I want the conditional formatting to use the MoM Delta value as its threshold lookup value. If I change the “Grouping to matrix” cell value to MoM Delta, I will get the correct cell coloring, but the table is not displaying the actual values
The expected cell value looks somewhat like below (value is Total Cost, cell highlight is based on MoM Delta):
















