Area under a transformation curve

Hi,

I have two datasets. Amps used by my house and energy produced by solar panels.

Query 1 retrieves amps and multiplies by 240v (roughly UK voltage until I get volt meter) giving watts used by the house.

Query 2 retrieves solar Watts being produces

I then use a transformation to subtract query 1 and 2 to get an approximation of what I’m getting from the grid or exporting to the grid.

This transformation curve is showing me Watts I’m importing or exporting from the grid based at a given time.
Where I live I get £y for exporting power but have to pay £x for my power.

I therefore want to “integrate” the transformation curve grouping positive and negative values to get watt hours export and import from the grid.

To Calculate watt hours from Watts before I’ve sumed Watts at intervals of 1seconds and divided by 3600 to get watthours.

However I’m not sure how

  1. I can do this to a transformation piece of data rather than from a database
  2. Is it possible to spit the sum to split negative and positive Watts ie imported vs exported power.