# kWh calculation confusion & flux monthly kWh calc

Any have a monthly total flux query for kWh?

Cant even seem to get the same influxQL query to output similar values.

SELECT integral(“value”) / 3600 / 1000 FROM “TotalPower” WHERE time >= now() - 7d and time <= now() GROUP BY time(1d) fill(null) tz(‘EST’)

vs

from(bucket: “iotawatt/autogen”)
|> range(start: v.timeRangeStart)
|> filter(fn: (r) => r._measurement == “TotalPower”)
|> aggregateWindow(every: 1d, fn: (column, tables=<-) =>
tables |> integral(unit: 1d), createEmpty: false)
|> map(fn: (r) => ({ r with _value: r._value / 3600.00 / 1000.0 }))
|> keep(columns: [“_time”, “_value”])
|> sort(columns: [“_time”])

If I comment out the map the returned values are.

|_value|_time|

|825.2188704|2023-02-11T00:00:00Z|
|2509.931949|2023-02-12T00:00:00Z|
|2724.521058|2023-02-13T00:00:00Z|
|2598.48512|2023-02-14T00:00:00Z|
|2891.021487|2023-02-15T00:00:00Z|
|2735.433436|2023-02-16T00:00:00Z|
|1889.49526|2023-02-17T00:00:00Z|
|1449.853233|2023-02-17T17:00:29.78875851Z|

Now I cant make sense of any of this. Reading what’s from the iotawatt graph+ show only 2 kWh for 2/17 my grafana calculation seems to be more correct reading 53.5 kWh. What am I doing wrong here???

I figured this all out iotawatt meter shows the daily average needs to be multiplied by 24