Dear Influx experts,
I want to show my power summation in Grafana dashboard (Stat Panel). However, I am having trouble with my query configuration.
The data is something like this.
10:00 am. 0
10:01 am 25
10:02 am. 20
10:03 am. 50
10:04 am. 53
10:05 am. 54
If I get the summation using the built-in summation aggregation,
It really adds the whole thing
However, this is not the kind of summation I want. What I want is to get the difference between the current and previous value and then it sum it up.
In my example above, the summation should be.
0 + 25 + 5 (difference between 25-20) + 30 (difference between 20-50) + 3 (difference between 53-50) + 1 ( difference between 54-53)
The summation should be = 64.
Kindly help me how am I going to achieve this.
Thank you very much.
What are you using InfluxQL or Flux?
Hi, I am using influxQL for this using the grafana query editor.
For how you describe it you need a non_negative_difference to get the single points. (non-negative otherwise the first one is 0-25 = -25)
You can then sum the values, either by using subqueries or by using Grafana itself (when using stat visual you get to choose a calculation to reduce the set to a single value, choosing “Total” will sum all the underlying values. (if you reduce it in the query itself any calculation should work as there will be nothing to reduce)
The query itself might look like this
non_negative_difference("Power") as PowerDiff
--to have just one value
SUM("PowerDiff") as PowerDiff
Hi thanks for this!
This is what I need! Thank you very much!