Trouble generating a monthly bar graph in flux/grafana

In the process of starting over with influxdb using V2, and having some trouble with monthly bar graphs. I’m feeding in watt data, and need to sort the data into days, and also convert from watts to KWH. I’m able to generate the graph with the following query, but this doesn’t do the last conversion to KWH. How do I format in the integral calculation?

from(bucket: “iotabucket”)
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “iotawatt”)
|> filter(fn: (r) => r[“sensor”] == “Solar”)
|> filter(fn: (r) => r[“_field”] == “Watts”)
|> aggregateWindow(every: 1d, fn: sum, createEmpty: false, timeSrc: “_start”)

Just an update. I managed to get this to work for a “this month” bar graph by day. Created a task that downsamples the data and converts to KWH, and then input that into the above query to get my chart.

Last issue is getting the annual chart to work. You’d think just swapping “1d” for “1mo” would give me the data monthly (and it does). But the values are wildly off. For example here’s what I’m getting in the graph:

But last month my solar was actually 702kwh, and consumption was 578kwh.