Wrong values when creating monthly energy usage chart

Hi there,
Starting over with influxdb using V2/flux, and having some trouble recreating the monthly bar graphs I had setup. I’m feeding in kwh data from my energy monitor, and need to sort the data into months. I’m able to generate the graph with the following query, but the values are totally wrong for some reason.

import “timezone”

option location = timezone.location(name: “America/Los_Angeles”)
from(bucket: “energybucket”)
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “iotawatt”)
|> filter(fn: (r) => r[“sensor”] == “Solar”)
|> filter(fn: (r) => r[“_field”] == “kWh”)
|> aggregateWindow(every: 1mo, fn: sum, createEmpty: true, timeSrc: “_start”)
|> map(fn: (r) => ({ _value:r._value, _time:r._time, _field:“Solar” }))

And here’s the chart I’m getting:

As an example, last month’s solar generated was actually 702Kwh, but the chart’s calculating it at 230kwh. What’s really bizzare to me is that I adapted this query from my monthly chart, and the values there are correct.

The actual cumulative value for solar should be about 1.15Mwh.

Hi @filmgeek47 Does swapping these two lines of your query produce a different (or perhaps correct) result?

Thanks for the reply! It turns out the issue wasn’t with my query. My task in InfluxDB had the wrong start range date, so it wasn’t counting the month I was checking as a reference point.