Noob influxdb2/flux arithmetic question

Greetings,

I’ve got my Iotawatt units feeding measurements into InfluxDBv2, but I haven’t quite wrapped my head around the basics of this Flux query language yet.

I have two CTs named I1_DTED1_L1 and I2_DTED1_L2. I would like to plot each of these CT Watt measurements, as well as the sum of both CT Wattages.

I can plot the two measurements with:

from(bucket: “iotawatt”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“ct”] == “I1_DTED1_L1” or r[“ct”] == “I2_DTED1_L2”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)

But I have no idea how to compute the sum of these two values and plot them as a 3rd plot on the chart even after doing some reading. Can anyone point me in the right direction here?

Thanks in advance!

The easiest thing to do would be to add another measurement in the influx setup screen to combine the two CTs into one measurement.

1 Like

Did you mean the Iotawatt setup screen, or the Influx setup screen?

If you meant Iotawatt, that does work well when both circuits are monitored by the same Iotawatt unit. But I am going to want to do arithmetic between circuits on two different Iotawatt units, so I think I will need to figure out how to do this at the Influx layer.

If you did mean the Influx setup screen, can you elaborate on what you mean / which screen you’re talking about?

I can gladly help. I am traveling right now but when I get home I can help you with Math

It is fairly easy once you understand the process

Sorry I didn’t have notifications turned on. Yes, I meant in the iotawatt screen. Yes, you are right if they are measured by two different you have to do it in the Influx layer.

I am not good with influx so I cannot help you there.