Hi there,
I would like to divide the measurement series into 8h segments if the selected time range is greater than or equal to 8h. With increase() I “reset” the value at a given Time so I am also using the offset parameter in the window() function.
|> window(every: 8h, offset: 4h)
|> increase()
When the selected time range is less than 8h, I do not need to window() and increase() the series.
So my question is, how can I calculate the difference from v.timeRangeStart and v.timeRangeStop to make an if-else statement in the query?
dataset = from(bucket: "statData")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "counterData")
|> filter(fn: (r) => r["_field"] == "counter")
if (d >= 8h) then
dataset
|> window(every: 8h, createEmpty: false, offset: 4h)
|> increase()
else
dataset
|> yield()