Cumulativesum per 24 hours

Hello

Thanks a lot to all of you who offer support to those in need! Very much appreciated! I have an issue I cannot resolve.

Context
I have a weather station (homematic IP) that for some reason zeros daily sums (e.g. rain) at 0700h and not at 0000h.

Goal
I would like to create a table (used to create a barchart in grafana) with daily sums from 0000h to 2400h.

Already acheived
I already managed to get a cumulativesum of the desired values over a timerange. Works like a charm:

from(bucket: "home_assistant")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) =>
      r._measurement == "mm" and
      r._field == "value")
  |> difference(nonNegative: true, columns: ["_value"])
  |> cumulativeSum(columns: ["_value"])
  |> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
  |> yield(name: "last")

Missing
Now from the above query I woul like to get daily cumulative sum that zeros at 2400h. I figured already that |> aggregateWindow(every: 1d, fn: last, createEmpty: false) returns nice daily “jumps” in the cumulative sum within the time range. But how can I tell the query that it shoud start at zero again every 2400h?

Any ideas?

Thank you!

Hello @akrea,
Can you try using the today() function in your range before applying 1d in your aggregate window function? today() function | Flux 0.x Documentation Also hello and thank you for being so kind :slight_smile:

Hi Anaisdg
Thank you for your suggestion. Unfortunately, it did not help.