# How do I plot the sum of three entities?

Hello everyone,
I somehow do not seem to find the obvious solution to my simply problem.

I have three entities which each give me a power consumption value. I have them all in separte graphs but I would also like on graph that shows the sum.

So if sensor 1 consumes 500 W, sensor 2 300 W and sensor 3 200 W, Grafana should show 1000 W as current consumption.
I thought it would be a simple math function, but I think I am mistaken.

Could someone point me towards the correct solution, please?

Thank you all
Alex

``````SELECT last("value") FROM "W" WHERE ("entity_id" = 'shelly_1pm_3c6105e5b756_power_0' OR "entity_id" = 'shelly_1pm_3c6105e588cd_power_0' OR "entity_id" = 'shelly_1pm_e8db84d4c0e3_power_0') AND \$timeFilter GROUP BY time(\$__interval), "entity_id" fill(none)
``````

Do the measurements from your three sensors have identical timestamps?

Antony.

Hello Antony,

do you mean if they always record a data point at the same time? If so, in theory probably yes. But that to me would not be relevant.

The data is more or less constant over a period of 2+ data points.
So even if the sensors’ data had a small time stamp difference, the sum would still be valid.

E.g.
sensor 1 at 0 sec = 100 W
sensor 2 at 0 sec = 100 W
sensor 3 at 0 sec = 100 W

→ sum at 0 sec = 300 W

Then let’s say time stamp is not the same and one would update after 10, one 15 and one 20 sec. Until then the previous value remains. Then

sensor 1 at 10 sec = 100 W
sensor 2 at 15 sec = 200 W
sensor 3 at 20 sec = 300 W

→ sum at 0 sec = 300 W (100+100+100)
sum at 10 sec = 300 W (100+100+100)
sum at 15 sec = 400 W (100+200+100)
sum at 20 sec = 600 W (100+200+300)