Hi there!
I am trying to do basic math operations with flux on InfluxDB 2.1.1.
Until now I was using InfluxDB 1.8. and I could use the query builder.
I am trying to do 2 things:
1st: to devide a value by 1000 (screenshot 1)
2nd: to multiplicate a value with a dashboard variable (“var1”) (screenshot 1)
Before flux language it seems to be so easy, but now I’m really struggeling to solve the same “easy” thing with flux.
After google, Grafana-Forum and Influxdata-Forum I came to this (screenshot 2). But, unfortunetely, its not working.
Do you have an idea how to solve this/ how to build the request properly?
Thanks!
Screenshot 1:
SELECT difference(mean(“value”)) / 1000*$var1 FROM “DG IT Strom Kanal 6 - Energiezähler - (Wattstunden)” WHERE $timeFilter GROUP BY time(1d) fill(none)
SELECT difference(mean(“value”)) / 1000 FROM “DG IT Strom Kanal 6 - Energiezähler - (Wattstunden)” WHERE $timeFilter GROUP BY time(1d) fill(none)
Screenshot 2:
from(bucket: “iobroker”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == “DG IT Strom Kanal 6 - Energiezähler - (Wattstunden)”)
|> filter(fn: (r) => r["_field"] == “value”)
|> map(fn: (r) => ({ _value: r._value / 1000 }))
|> cumulativeSum(columns: ["_value"])
|> aggregateWindow(every: 1d, fn: mean, createEmpty: false)
|> difference()
|> yield(name: “mean”)