# Cumulativesum per 24 hours

**URL:** <https://community.influxdata.com/t/cumulativesum-per-24-hours/20967>\
**Category:** Dashboards\
**Tags:** grafana, query, flux\
**Created:** [July 29, 2021, 8:32pm UTC](https://community.influxdata.com/t/cumulativesum-per-24-hours/20967 "2021-07-29T20:32:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akrea](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/akrea/32/6618_2.png) [@akrea](https://community.influxdata.com/u/akrea)\
**Post date:** [July 29, 2021, 8:32pm UTC](https://community.influxdata.com/t/cumulativesum-per-24-hours/20967/1 "2021-07-29T20:32:31Z")

</div>

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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [July 30, 2021, 6:11pm UTC](https://community.influxdata.com/t/cumulativesum-per-24-hours/20967/2 "2021-07-30T18:11:40Z")

</div>

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](https://docs.influxdata.com/influxdb/cloud/reference/flux/stdlib/built-in/misc/today/) Also hello and thank you for being so kind 🙂

---

<div class="post-metadata">

**Author:** ![akrea](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/akrea/32/6618_2.png) [@akrea](https://community.influxdata.com/u/akrea)\
**Post date:** [July 30, 2021, 7:30pm UTC](https://community.influxdata.com/t/cumulativesum-per-24-hours/20967/3 "2021-07-30T19:30:21Z")

</div>

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