Unexpected results when combining multiple "Add field from calculation" transformations

Using Grafana v13.1.0, I am trying to find old images and image missmatches running in multiple kubernetes clusters.

Normally I would expect that all pods/containers across all cluster/namespace combinations run the same version, but there might be clusters (probably), or even different pods in a deployment (hopefully not) that might differ.

I have a PromQL query that will give me columns

  • cluster,
  • namespace,
  • image_name,
  • image_version,
  • count

which gives me enough information.

I am now looking to generate a table like:

image/cluster Cluster 1 Cluster 2 Cluster 3 Change Count
image 1 v1.2.3 v1.2.3 v1.2.3 0
image 2 v42 v23 v42 1
image 3 v42-dev1 v42 v42, v42-dev1 1

My goal for the “Change Count” column is to color-code rows with different values and to hide it later.

I started with the query and added a transformation “Add field from calculation” which gives me the list of version for unique cluster/namespace/image_name combinations:

And I have the transformation “Grouping to matrix” to generate the “main” part of the above table:

I then thought of adding another “Add field from calculation” with the calculation set to “Changes Count”:

What I did not expect was that each column was counted as “changed”:

Did I find a bug or am I doing something wrong?

Hi @Snafu Welcome to the community

“Grouping to matrix” overwrites, doesn’t merge

If a cluster runs the same image across multiple namespaces with different versions, “Grouping to matrix” keeps only one and silently drops the rest. Add field from calculation (Reduce row) won’t fix this → it reduces across fields in the same row, not across multiple rows. Use Group by first to merge those rows.

“Change Count” flags every column as changed

“All unique values” returns a JS array, not a string. Change Count compares with strict inequality (!==), and two arrays are never equal even with identical contents → so every column reads as “changed.” (Distinct Count has the same issue, since it uses a Set.) Fix: convert that field to a string before it reaches Change Count.

Before the fix, every row gets the same Change Count regardless of whether the versions actually differ:

Fix →
Group by

  • Group by: cluster, image_name (leave namespace ignored)
  • On image_version: Calculate → All unique values

Convert field type

  • Field: the merged image_version (uniqueValues) field
  • As: String
  • Join with: ,

Grouping to matrix

  • Column: cluster
  • Row: image_name
  • Cell value: the converted string field from step 2

Add field from calculation

  • Mode: Reduce row
  • Operation: select the pivoted cluster columns
  • Calculation: Change Count
  • Alias: Change Count


Result: grafana/loki-canary → 0, oss/csi-node → 1, mirror/calico → 2 (with cluster-a correctly showing both v3.31.2, v3.31.5 from two namespaces on the same cluster).

Hi @Snafu just wanted to check if you got the solution . Happy to help further if you are facing any issues .