Calculate and display monthly Watt production

I would like to get the value of produced Watts of each month.
Unfortunately, I go get the value of the second month, but the value of the first month is missing.
In November it was 17.9 kwh in October it was 300wh but all I see is 300wh in October.

My current query is:

from(bucket: “XX”)
|> range(start: -11mo)
|> filter(fn: (r) => r[“_measurement”] == “XXXXXXXXXXX”)
|> filter(fn: (r) => r[“_field”] == “pvenergytotal”)
|> toFloat()
|> map(fn: (r) => ({r with _value: r._value / 10.0}))
|> aggregateWindow(every: 1mo, offset: -2h1m, fn: last)
|> difference()

With “difference()” at the end:

Any idea how I get the value of November as well?

…And here without “difference()” at the end:

I think your question may be more of a Grafana question, but since this is the InfluxDB forum, I thought I would share some data & queries that may be helpful.

I collected my kWh every hour from January thru August (8 months, or 243 days)

Here is the data by hour (5832 points on the graph, or 243 x 24)

Here is the data by day (243 points on the graph)

Here is the data by month (8 points on the graph):

Note that I am aggregating the data differently in each of the above. I am using the fn: mean to collect the arithmetic average of the hourly values collected (the average of 24 readings in the 1d aggregateWindow, and the average of all hourly readings during the month in the 1mo aggregateWindow).

Questions for you:

  1. What does your query look like in Influx Data Explorer?
  2. Why do you have the range |> range(start: -11mo) ?
  3. Why do you have the difference() function?

You are absolutely right, sorry for sharing a Grafana Screenshot. The result is the same for Influx.
I have two values. One that I could use is the daily produced kwh (pvenergytoday), In my case I used pvenergytotal which stores the total value of produced kwh from day 1 on.

Why do I use the difference() function?
With my query I try to get the pvenergytotal per month and calculate the difference of each time sequence sequence (here one month).
So in October I’ve had none (NULL), in November I’ve had 17,9kwh and in December I’ve had 300kwh so far.
As October is NULL I would expect that the difference to November is 17.9kwh and the next difference to 18.2kwh in December is 300wh, which I can see in the graph. But I don’t see the 17.9kwh in November.

Another attempt could be to sum up all daily values of a month (pvenergytoday) and display them for each month.

Why do I use the range of

|> range(start: -11mo) ?

This is because I would like to see the produced kwh of each month on comparison to the other months and 11 month back in the past.

My Query with (differernce()) in Influx:

And the request with yield() (which as far as I know is assumed in each query anyhow, even if you dont write it down):

What happens if you change the aggregateWindow function to fn: sum?

from(bucket: “XX”)
|> range(start: -11mo)
|> filter(fn: (r) => r[“_measurement”] == “XXXXXXXXXXX”)
|> filter(fn: (r) => r[“_field”] == “pvenergytotal”)
|> toFloat()
|> map(fn: (r) => ({r with _value: r._value / 10.0}))
|> aggregateWindow(every: 1mo, offset: -2h1m, fn: sum)
|> difference()

This example returns -14900 as a value of December and still no value for November.

Anyone who is able to help me?