How to - Cumulative sum for kWh that resets daily

Hi,

In an Influx database I have watts being logged and have a CQ that creates kWh data.

I would like to graph cumulative kWh consumption during the day to show energy usage that grows throughout the day and the reset to zero each day as shown in the attached screenshot.

I am new to Influx and Grafana and have hit a deadend. Could somebody please help - is it possible and where do I start.

Any help greatly appreciated.

thanks
Paul

1 Like

Influxdb should have an integral function that you can use

I am using the Integral function in the continuous query in Influx to create Wh (watt hours) out of watts but I cant see how to use it to create a cumulative sum that resets to zero each day like the saw tooth pattern in the screenshot.

1 Like

I found the solution, see my documentation here: https://stackoverflow.com/questions/53711110/make-cumulative-function-that-resets-daily

In short:

SELECT kaifa-kaifa_fill as Energy FROM
  (SELECT first(kaifa) as kaifa_fill from energyv2 WHERE $timeFilter group by time(1d) TZ('Europe/Amsterdam')),
  (SELECT first(kaifa) as kaifa from energyv2 WHERE $timeFilter GROUP BY time($__interval))
fill(previous)