# Average electricity based on SPOT and consumption

**URL:** <https://community.grafana.com/t/average-electricity-based-on-spot-and-consumption/135992>\
**Category:** InfluxDB\
**Created:** [November 8, 2024, 12:57pm UTC](https://community.grafana.com/t/average-electricity-based-on-spot-and-consumption/135992 "2024-11-08T12:57:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![olde](https://avatars.discourse-cdn.com/v4/letter/o/a3d4f5/32.png) [@olde](https://community.grafana.com/u/olde)\
**Post date:** [November 8, 2024, 12:57pm UTC](https://community.grafana.com/t/average-electricity-based-on-spot-and-consumption/135992/1 "2024-11-08T12:57:58Z")

</div>

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

 ![MLP](https://us1.discourse-cdn.com/grafana/original/3X/e/b/eb3d2288b774e0cbec8c22f14bd307c09288f57a.png)

---

<div class="post-metadata">

**Author:** ![grant2](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/grant2/32/42281_2.png) [@grant2](https://community.grafana.com/u/grant2)\
**Post date:** [November 8, 2024, 5:47pm UTC](https://community.grafana.com/t/average-electricity-based-on-spot-and-consumption/135992/2 "2024-11-08T17:47:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![olde](https://avatars.discourse-cdn.com/v4/letter/o/a3d4f5/32.png) [@olde](https://community.grafana.com/u/olde)\
**Post date:** [November 8, 2024, 5:48pm UTC](https://community.grafana.com/t/average-electricity-based-on-spot-and-consumption/135992/3 "2024-11-08T17:48:04Z")

</div>

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.

 ![MLP_1](https://us1.discourse-cdn.com/grafana/original/3X/d/2/d2afdf1000fcc4b307d9cf04f7f41405bb927a79.png)

---

<div class="post-metadata">

**Author:** ![olde](https://avatars.discourse-cdn.com/v4/letter/o/a3d4f5/32.png) [@olde](https://community.grafana.com/u/olde)\
**Post date:** [November 8, 2024, 6:05pm UTC](https://community.grafana.com/t/average-electricity-based-on-spot-and-consumption/135992/4 "2024-11-08T18:05:49Z")

</div>

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.

 ![IMG_7711](https://us1.discourse-cdn.com/grafana/original/3X/5/4/54f8feef04f85c78e392f733a30d931370fec4e2.png)

---

<div class="post-metadata">

**Author:** ![grant2](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/grant2/32/42281_2.png) [@grant2](https://community.grafana.com/u/grant2)\
**Post date:** [November 8, 2024, 6:24pm UTC](https://community.grafana.com/t/average-electricity-based-on-spot-and-consumption/135992/5 "2024-11-08T18:24:14Z")

</div>

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](https://grafana.com/blog/2023/12/29/a-comparison-of-influxql-sql-and-flux-query-languages-for-grafana-dashboards/)
