I have two measurements and would like to combine the values from both to perform an additional calculation (Total = PowerIn + pv_wirkleistung - PowerOut). Unfortunately I do not know how to do this. Could someone maybe help me?
I’ve found that the current GUI is a bit of a challenge with advanced queries like this that combine several expressions into one. That said, I don’t think you need the yield lines since you’re already assigning each statement into data1 and data2 variables. Unless you know for sure the temp variables won’t work without them.
Doing math between temp data variables however isn’t something I’ve done yet.
From a quick browse through the docs, it was mentioned that operands for a math expression needed to be in the same row.
(Take with grain of salt) if true, then you’ll need some way to join the input/output values with the values in the inverter set. Timestamp might work, but they have difference precision - is that expected? If yes and you’re only sampleing every second, you could truncate the input/output timestamps to nearest whole second and use that.
Take a look at the sql examples at the very bottom of this page - the join operation is likely very similar to what you need.
Finally , There’s quite likely serval different ways to do this too. Let us know how you go.