Hi, New to influx and im trying to display energy usage per day(7day view) and monthly total.
My data is cumulative
0 | energy | Canal_Side_Supply_KWH_Value | 76722665 | 2022-06-03T06:57:56.117Z | 2022-06-10T06:57:56.117Z | 2022-06-03T07:00:00.000Z | U_Energy_Flux |
---|---|---|---|---|---|---|---|
0 | energy | Canal_Side_Supply_KWH_Value | 76722780.66666667 | 2022-06-03T06:57:56.117Z | 2022-06-10T06:57:56.117Z | 2022-06-03T07:30:00.000Z | U_Energy_Flux |
0 | energy | Canal_Side_Supply_KWH_Value | 76722997.86666666 | 2022-06-03T06:57:56.117Z | 2022-06-10T06:57:56.117Z | 2022-06-03T08:00:00.000Z | U_Energy_Flux |
0 | energy | Canal_Side_Supply_KWH_Value | 76723218.53333333 | 2022-06-03T06:57:56.117Z | 2022-06-10T06:57:56.117Z | 2022-06-03T08:30:00.000Z | U_Energy_Flux |
0 | energy | Canal_Side_Supply_KWH_Value | 76723440.46666667 | 2022-06-03T06:57:56.117Z | 2022-06-10T06:57:56.117Z | 2022-06-03T09:00:00.000Z | U_Energy_Flux |
0 | energy | Canal_Side_Supply_KWH_Value | 76723667.2 | 2022-06-03T06:57:56.117Z | 2022-06-10T06:57:56.117Z | 2022-06-03T09:30:00.000Z | U_Energy_Flux |
0 | energy | Canal_Side_Supply_KWH_Value | 76723893.46666667 | 2022-06-03T06:57:56.117Z | 2022-06-10T06:57:56.117Z | 2022-06-03T10:00:00.000Z | U_Energy_Flux |
What im trying to achive is the following with enegy usage for each time window ie 00 - 07 tariff 1 and 07 - 00 tariff 2
what im struggling with is to display the difference between a set time rage that spans over multiple days
this is what i have so far, this is one query for 00-07 and i have another one for 07-00
import “date”
from(bucket: “utilities”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “energy”)
|> filter(fn: (r) => r[“LogGroup”] == “U_Energy_Flux”)
|> filter(fn: (r) => r[“_field”] == “Canal_Side_Supply_KWH_Value”)
|> filter(fn: (r) => {hour = date.hour(t: r._time) return hour >= 0 or hour < 7})
|> aggregateWindow(every: 1d, fn: last, createEmpty: false)
|> difference(nonNegative: false, columns: [“_value”])
i think i need to eithe use max - min or map to condition my data but thats where im failing
any help would be apriciated
thanks