Grafana (Influxdb): Show graph for difference between to measured values

I’m measuring my heaters and specially the temperature of water going into the boiler and coming out of it.
So i managed to get both values, which are stored in the DB like “temp_in” and “temp_out”.
I am able to visualize both measurements in one panel, so i see temperature rising and falling.
But still i like to add one more graph / value to the panel, which is not measured, but calculated form both values, which would be “temp_in - temp_out”. Means: i want to see the difference between heated and non-heated water as a separate graph.
Of course i can go into openhab and create a virtual item + rule, which would do the calculation and write its value into the DB, but this is not the right way i think, as it is one more measurement running permanently.
Trying for several hours already, but cant manage to visualize it.
Please give me a hint ^^

This is a grafana specific issue then.
Have you tried their forum?

Not yet. Just thought someone here got the same problem or maybe know how to set function in grafana.
Saw someone with exactly the same problem in their forum, who quit discussion with “ok, found a solution b myself. bye” post.
I love such :roll_eyes:

Something like that?

This is Power production minus Power consumption.
But I have to admit, that Consumption is stored with negative value. I have no Idea if it’s possible to do more math in grafana, this graph is “two channels stacked”.

1 Like

You can do it in grafana assuming you’re using mysql storage.
You’ll have to write two queries in grafana. Each query needs to average the values to some common point in time, say 5 minute blocks.
Now you’ve got two datasets which line up in time.
A third query comes one - the other to give you the third graph.

The virtual item is the best option though as its far more lightweight than hitting the db 3 times.

1 Like

Yep. got found this “stack” option.
Sadly the non-heated water is still a positive value and grafana keeps on sum-function, so as result i get the non-heated water, heated water and even super-heated water :grin:

Guess it’s really the easiest way to keep with a third virtual item, like @CDriver said.

Thx guys