How to use if condition here. I am getting the data by using all the filters and I am also using a tag value as a variable and I want to execute the next steps only if the tag value is equal to line 2 else I need the query to return 0. I’m new to influx and coding. So apologise my ignorance. this is my query
from(bucket: “BJ”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “REJECTCOUNTERS4”)
|> filter(fn: (r) => r[“_field”] == “counterIN”)
|> filter(fn: (r) => r[“line”] =~ /^${line:regex}$/)
|> if r[“line”] = “2l” then (
|> filter(fn: (r) => r[“machine”] == “Cognex3”)
|> aggregateWindow(every: 1m, fn: last)
|> difference(nonNegative: true)
|> sum()) else return 0
It would be helpful if you correct my query