Calculate sums between events

Hey there,

i have a question about data handling in Grafana.

Target: Calculate driven range between battery loadings.

I have 2 different Influx Datasources. A has data about loading the battery. B has data about the driven ranges.

I can show booth sources as “mixed Datasource” into a graph. So I get a bar for loading, 5 bars for driven ranges, the a loading bar again and so on.

What I want is, to get a sum of the ranges between the loadings.

battery loading
driven 4km
driven 2km
driven 8km
driven 15km
driven 4km

should shown as
driven (sum) 14km
driven (sum) 19km

So is it possible to do that in Grafana ?

Thank for help

I believe that using Flux, you could accomplish this by summing all values where the tag “driven” = TRUE. When “loading” the tag “driven” would be “false”. Not sure if that is how you set up your data, but it should be possible to create a map function that looks for a positive driven value.