Mathematical operations in Query Editor

Hi everyone,

I successfully installed InfluxDB 2.0 in my Docker environment. I am logging the power consumption of my house and also my solar power production. I was able to build a great looking dashboard in Chronograf 1.8!
Now I would like to improve my dashboard and do some mathematical calculations. Is it possible to do that in the query builder? As far as I can remember it is possible in Grafana but I was not able to find an easy solution for Chronograf.
An example would be:
powerCH1 + powerCH2 + powerCH3 - solarCH1 - solarCH2 = overall_consumption
powerCH1,… are my fields
How can I achieve that?
Thank you very much for your help!

Tom

1 Like

Hello @digohm,
Welcome! Yes you can build that with the query builder in 2.x. Or you can switch over to the script editor.
Your flux query would look something like this:

from(bucket: "system")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "mymeasurement")
  |> sum()
  |> yield(name: "sum of my fields")