InfluxDB2 - Calculate Total Consumption as 'Sum per day'

  • What Grafana version and what operating system are you using?
    Grafana v10.2.3
  • What are you trying to achieve?
    I measuring the daily consumption of my coffee machine and would like to sum up the daily values to calculate the total consumption of the heater. I have following data:

Day 1: 5
Day 2: 4
Day 3: 6
Day 4: 5

Now, I would like to sum up the individuals values so that I arrive at 20 and then display it on a bar chart

  • How are you trying to achieve it?

from(bucket: “iobroker”)
|> range(start: -10d, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “Coffee”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: 1d, fn: max, createEmpty: false)
|> sum()
|> yield(name: “max”)

This does the calculation (see below) but I am not able to put this on a chart.

  • What happened?
    When I try to display a chart, I get the following message