Hello,
New to InfluxDB, I’m switching from MySql to influxDB 2.0
I’m so converting my mySQL queries to Flux.
I’m trying to calculate the difference between min and max of a range.
Here is what I tried:
datamin = from(bucket: "grafana")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "history")
|> filter(fn: (r) => r["_field"] == "value")
|> min()
|> aggregateWindow(every: 1s, fn: unique, createEmpty: false)
datamax = from(bucket: "grafana")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "history")
|> filter(fn: (r) => r["_field"] == "value")
|> max()
|> aggregateWindow(every: 1s, fn: unique, createEmpty: false)
Both independently are giving the correct values. Now I just want to show the difference but I don’t find the correct syntax. Below is the schematic idea of what I like to do
(datamin-datamax)
|> yield()
Please help me for the correct syntax. Or maybe there is a more direct way to get this ?..
Thanks !