from(bucket:"bucket1")
|> range(start: 0)
|> filter(fn: (r) =>
r._measurement == "Data1"
or r._measurement == "Data2"
or r._measurement == "Data3"
or r._measurement == "Data4")
|> group(columns: ["_measurement"])
|> HandleData()
And I want to create a function called HandleData, which will perform aggregation on all the input tables according to the measurement field.
I mean something like this:
HandleData = (tables=<-) =>
{
val = if _measurement == "Data4" then average(_value)
else sum(_value)
o = {measurement: _measurement , value: val}
return o
}
I couldn’t find any lead on how to solve this until now, I will highly appreciate any help in solving this matter.