My Influxdb 2 measurement contains a boolean field. I would like to formulate a query that outputs all rows where the field's value is true. An if
condition in a filter line does not work.
In detail: I have workout data that includes the boolean field "isIndoor". I want to visualize all values in my dashboard if that field is not true. (I can rename/filter/map values/fields in later steps.)
from(bucket: "mydata")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => if r._boolean == true then
// use all the fields
else
// actually, there shouldn't be an 'else' but Flux insists on it
)
// further treatment and filtering
How can this be accomplished?
New edit: I found out that by pivoting the data I can use a filter:
from(bucket: "mydata")
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> filter(fn: (r) => r["isIndoor"] == true)
Regrettably, now Grafana no longer recognized the output as graphable. I am now considering to empty the bucket and fill it with my data again but use the boolean value as a tag.