Show the right consumption value

Hi everybody, it seems pretty easy but I found very difficult to calculate various value of my daily consumption. Im using InfluxDB and latest version of Grafana along with a Shelly EM. The data I received are inconsistent (the shelly EM use MQTT protocol to send the data and It doenst send it every X second but it send randomly (more or less 10-15 per minute) The power comes in Watt. Now I just want to obtain:

  • The MIN, MAX and CURRENT value in the $_intervall period
  • The daily cost
  • The monthly approx usage cost
  • The cost per day in a month graph
    This is what I got

    At the bottom it says min 47Watt and that is precise in my graph at the top it said 85Watt and it isnt correct, this is the influx query:
    SELECT min(“value”) FROM “power” WHERE $timeFilter GROUP BY time(1d) fill(none)

This is 24H power usage
SELECT sum(“value”) FROM “power” WHERE $timeFilter GROUP BY time($__interval) fill(null)

This is average home consumption
SELECT mean(“value”) FROM “power” WHERE $timeFilter GROUP BY time(1m) fill(null)

This is daily power cost
SELECT mean(“value”) /1000240.22 FROM “power” WHERE $timeFilter GROUP BY time($__interval) fill(null)

This is estimated monthly power cost
SELECT mean(“value”) /10003024*0.11 FROM “power” WHERE $timeFilter GROUP BY time($__interval) fill(null)

Finally the cost per each day graph and this is totally broken

(Due to new users I cant upload more than 2 images sorry)

Can someone help me to find out the correct formula? Thank you
Also im struggling understanding the GROUP BY, because Im not sure what it return back when I used it. In theory it should give me, in the case it is group by time(1d), a dew group that contains the all 1day results