Cumulative sum over time

Hello

I’m trying to simply display the cumulative sum of my rain gauge over a certain periode of time.

The rain gauge has a 5min resolution , that i would like to see over one 1hour
As you can see on the graphs , the cumulative sum almost work but never goes back to zero when it doesn’t rain

SEE HERE >Graphics

Does anyone can help me plz

Thx

yes off course you need a function non_negative_difference and group by manybe one hour or whatever you like

Thanks for your support,

I tried a non negative difference with a distinct and a sum function . In both case i was expecting something different:

Foa a SUM i’don’t understand why it goes to 0 between 6am and 7 am test-Grafana-Mozilla-Firefox-2 — ImgBB
(I was expecting a 4) because the rain gauge has counted 4 times

For a distinct it’s more bizar > test-Grafana-Mozilla-Firefox-3 — ImgBB

ui, this is looking strange, i use this formula
SELECT (2* non_negative_difference(last(“value”))) FROM “factory1.throughput22.porkhalves.inc” WHERE $timeFilter GROUP BY time(1d)

please adapt for your needd