I have a set of data with a little calculation, now I want to calculate the result through different way with different time frame.
I original query
binance = from(bucket: "mainbucket")
|> range(start: timeRange)
|> filter(fn: (r) => r["_measurement"] == "Balance")
|> filter(fn: (r) => r["_field"] == "bitGet1")
|> filter(fn: (r) => r["type"] == "bitGet")
|> aggregateWindow(every: 5m, fn: last, createEmpty: false)
join(tables: {ftx:ftx, ba:binance}, on: ["_time"])
|> map(fn: (r) => ({
_time: r._time,
_value: (r._value_ftx + r._value_ba)
})
)
|> movingAverage(n: 5)
|> yield(name: "last")
Now I want to make result:
(r._value_ftx + r._value_ba) if date <= 2022-09-01
(r._value_ftx + r._value_ba)/2 if date is between 2022-09-01 and 2022-10-01
(r._value_ftx + r._value_ba)/3 if date is > 2022-10-01
Please help to write the logic with flux, thanks.