How to compare 3 fields in the measurement to create new field and set new field as output?
Can you please help me with the query ?
I was trying below query…
from(bucket: "bucketName")
|> range(start: -3h)
|> filter(fn: (r) => r["_measurement"] == "measurementName")
|> filter(fn: (r) => r["_field"] == "col1" or r["_field"] == "col2" or r["_field"] == "col3")
|> aggregateWindow(every: 5s, fn: last, createEmpty: false)
|> drop(columns:[list_of_column_names])
|> map(
fn: (r) => ({ r with
_field: "flag",
_value: if ((r._field == "col1" and r.value > 80) and (r._field == "col2" and r.value > 80) and (r._field == "col3" and r.value > 80)) then 1 else 0,
})
)
|> filter(fn: (r) => r["_field"] == "flag")
But it doesn’t seem to give me an expected output…