Intregral from already transformed (filtered) values

Hi All,

I have two queries - one displays the wattage my house is drawing from the grid and the other is measuring the engergy level (in %) of my PV battery.

What I am trying to achieve is to understand how much energy (Wh) is drawn from the grid while the battery was empty.

I managed to create a query which filters the wattage based on the battery status und replies only the values in question:

So far so good - but now I need to create a integral for the values and I don’t know how?

Any ideas?

Thanks
Stefan