How to set units per row in a Table after Transpose transformation?

What Grafana version and what operating system are you using?

Grafana v12.2.1

What are you trying to achieve?

I want to use a Table panel to display metrics in rows, with the correct unit for each metric. For example:

  • Température local | 20.5 °C

  • Température sonde | 21.1 °C

  • Humidité | 55 %

How are you trying to achieve it?

My data source returns data in a wide (time-series) format:

Time Température local Température sonde Humidité
20.5 21.1 55

To get the row-based layout I want, I’m using the Transpose transformation. This gives me a table with “Metric” and “Value” columns:

Metric Value
Température local 20.5
Température sonde 21.1
Humidité 55

What is the problem?

Before transposing, I could use a Field Override on fields matching /Température/ to set the unit to Celsius.

After transposing, my only fields are “Metric” and “Value”. I can set the unit for the entire “Value” column, but I can’t figure out how to set the unit based on the content of the “Metric” column (e.g., “if ‘Metric’ contains ‘Température’, set unit to Celsius”).

Question:

Is there a way to apply “per-row” units to the “Value” column based on the “Metric” column’s value? Or is there a different transformation I should be using to get this layout and have correct units?

I applied a field override to set unit Celsius to every field whose name contains “Température” except I would like the data to be transposed. When applying the transpose transformation, I cannot override units per row. Is there any way to achieve this?

I believe in Table it will not be possible, because overrides can be applied only to columns. But may be you can use stat panel to display your data as a workaround, without Transpose transformation:

Another option would be to update query in your datasource so as it returned value + necessary unit strings

look into the new SQL Expression

If you can’t change query in your datasource so as it returned value and unit, you may try new SQL Expressions feature

1 Like

Awesome, SQL Expressions seems to be the way!

Table looks much better than the Stat panel in my case.

Thanks to both of you.

1 Like