Calcurate power price over time

Im trying to create a dashboard that shows the power usage and price, and total price for that time period.

I have InfluxDB set up, but im using the simple query method instead of FluxDB.

I already have the price in the influx db, with price for each hour, and the same with power usage, but when i try to add them togerther i get a price thats 60% short of my real bill.

I also got a script calcurating my avg power price, do i use that to calcurate the total price for the period, its pretty close to the real price.

This is how its setup:

I have created a stat row to show the data, that looks like this:

the Power Usage 1014 is the correct power usage for the time period. But the price is 60% off… do i add the price to a time series graph it looks correct, with the correct power price with tax and so on, for each month.,

Any idea whats wrong with the way im multiplying the values togerther?

This is how the multiply one is done

Welcome @madsholme to the Grafana forum.

Are you adding or multiplying or both?

I believe the incorrect result (whether adding or multiplying) might be due to the fact that the timestamps of both price and usage are not identical. It looks like usage is being reduced to a single value using MEAN…try changing it to LAST, even though I know that does not make sense, just to see if the math works.

Thanks for the welcome.

im only multiplying… usage pr hour * hourly rate, at least that was what i was trying to do.
Changing both to use last() gives the same value as using mean()

I tried to add groupby time(1h) as each value is for one hour. But again it gives the excact same results.

Here you can see the output table.