The column route contains 4 unique values and appearing many times, they are A100, A110, A120, A140. I want to convert A100 and A110 to group A and A120 and A140 to group B. Then I want to group by route and want to have 2 rows only, A and B and their aggregated value.
How are you trying to achieve it?
by using value mapping. This is what I have done, followed by ‘group by’ transformation.
What happened?
It’s grouping the data, but A and B both appearing 2 times. This is what I’m getting-
What did you expect to happen?
I’m expecting both A and B to be appeared one time each with corresponding aggregated value as group by transformation applied. the expected output should be as below-
I personally try to avoid grafana transformation if at all possible (it can get very hairy and unmaintainable) and try to do what I need in the data source itself
Here is one approach using jsonata which is a feature of infinity plugin. Nice and clean and readable. You can even take it further and do your counts in jsonata itself to get your final data as you want it to look like.
@joachimschiewek, Thank you for replying and your answers seems to be very straightforward. However, I’m only allowed to use infinity as data source, and I don’t have permission to install ‘Static DS’ as I’m on editor role.
Hi @yosiasz,
Thank you for replying. Since I’m very new to Grafana, I’m trying to figure out how to use jsonata without any luck as I haven’t seen any option for jsonata.
@yosiasz , I was able to use jsonata in a very basic way as i’m very new to it and as I have just have started learning. While a single line of code is working in jsonata, but that very same code (copied and pasted) in uql editor is not working? Please see the image for reference.
I have also tried to put the whole code into one line.But its not getting any data either. Am I not supposed to use exact query that worked in jsonata?
The data has been taken from Grafana playground, however, you can have it here.