Use Group-By Transformation to get Entry with Max-Value (arg_max in Kusto)

  • What Grafana version and what operating system are you using?
    Grafana v9.5.13 (802385ecac) (Azure Managed Grafana)

  • What are you trying to achieve?
    I have two queries, that I am merging. Afterwards I want to group the results by one column and get the values from the record that has the highest value for a certain property.

Query Result1:
| Item | Order |

| ItemA | OrderX |
| ItemB | OrderX |


Query Result2:
| Item | Weight |

| ItemA | 24g |
| ItemB | 217g |


Now after merging I get

| Item | Order | Weight |

| ItemA | OrderX | 24g |
| ItemB | OrderX | 217g |


Now I would like to group by Order and get the record, that has the highest weight,so I want:
| Item | Order | Weight |

| ItemB | OrderX | 217g |


  • How are you trying to achieve it?
    I tried the group by function, but none of the calculation seem to do what I want. I also tried to achieve this via an expression of the queries, but to no result. I also read through all other transformations, but I have not come up with a series of transformation, that would achieve what I am going for …

Solved it myself. I put the result of one query into a variable, formattet as Json. Then I deserialized that data in kusto and merged it with my other datasource, all in the Kusto Query.