Monthly usage based on daily cumulative values

Hi all,

I have data stored from my energy meter which looks like this:


after this query:

currentvalues = from(bucket: "smarthome")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "ElectricalEnergy")
  |> filter(fn: (r) => r["Scope"] == "House")
  |> filter(fn: (r) => r["Source"] == "SaiaBurgess")
  |> filter(fn: (r) => r["UpdateInterval"] == "Day")
  |> filter(fn: (r) => r["_field"] == "value")
  |> truncateTimeColumn(unit: 1m)

So, a value every day at midnight (in reality, they are some seconds after midnight why I truncate them).

How can I now get the monthly usage? I’ve tried so many things with aggregateWindow, timeshift and all that it would take too long to explain it all here. I think one of the “problem” is, is that the consumption of e.g. January hast to be calculated until 00:00 on Feb 1st. As this is already Feb. I don’t know the correct way of taking this into account.

Did anyone already do that?

Many thanks,

Hello @Sparx82,
Until or including 00:000 Feb1?
It could be related to:

Including Feb1 00:00 because this is the value of the last day of January.

Hello @Sparx82,
Can you try the offset example in the gh issue linked above?