Average electricity based on SPOT and consumption

Newbi asking what I need to do, in order to get grafana to calculate average electricity price (cent/kWh).
Consumption data is read once every hour and stored into influxDB as well as Spot market price. Cost for each hour is calculated with Expression (consumtion * spot). This cost is then divided using a second expression (Cost / consumpition) to obtain snt/kwh for each hour.
Now I’m stuck since I cannot figure out how for sum up the individual hours before the calculation (cost/consumption) is performed.

Eventually this will be a gauge or pie chart, but expressed it here as time serial to make the datapoints visible. Thank you for your help

Welcome @olde to the forum.

Are you using InfluxQL, Flux, or SQL to write your queries? Have you tried anything thus far that you can share?

To elaborate the above, even better would be if i could make the kWh and cost cumulative curves for given time rage.
Query reads and sums up the kWh from theee phases.
$B is spot price for electricity and the 0,45 is my contract margin.

Thank you Grant2

I’m totally trial and error type user of Grafana and IT is not my ”territory”, but slowly and surely I have able to slab the below dashbord together.
Databases mainly influxDB but spot pricing is SQL.

This current obtacle is something I could not solve, thus in practice I know what is needed, but cannot find the ”right tools” for that.
I have tried with different tools from ”transform”
but without success.

I see you are using InfluxQL, which is unfortunately the most limited of the 3 query languages that InfluxDB offers. I’ll have a look at your questions when I have some time and see if I can give you some pointers, but I do not use InfluxQL much.

Here’s an article that may help you. A comparison of InfluxQL, SQL, and Flux query languages for Grafana dashboards | Grafana Labs

1 Like