Hello,
I’m extracting two data streams to measure my electrical consumption and the production of my solar panels. I would like to make the difference between these two values.
Here is my current QL:
Pv=from(bucket: "jeedom2/autogen")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "Consommation Totale O" or r["_measurement"] == "Consommation Totale 1")
|> filter(fn: (r) => r["_field"] == "Shelly 3EM")
|> aggregateWindow(every: 1h, fn: max, createEmpty: false)
|> difference()
|> group()
|> aggregateWindow(every: 1h, fn: sum, createEmpty: false)
|> yield(name: "Conso")
Conso=from(bucket: "pv/autogen")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "2120198970" or r["_measurement"] == "2120199320" or r["_measurement"] == "2120199323")
|> filter(fn: (r) => r["_field"] == "energy")
|> aggregateWindow(every: 1h, fn: max, createEmpty: false)
|> difference(nonNegative: true)
|> group()
|> aggregateWindow(every: 1h, fn: sum, createEmpty: false)
|> yield(name: "Pv")
How do i create the difference between the Pv streams and the Conso Streams.
Thanks