Calculation time based if value is > 0

Hey everyone,

i try to calculate the cost for energy used to a day for some appliances.
So i got knx actors that is sending its data on every change to the influxdb (via openhab). I got Wattage (Current timewise) and Ampere (also Current timewise).

let me give you a visual aid:

So, i need to sum up the wattage for a given period - f.e. 1 day, divide it by 1000 and multiply it by the cost of one kWh.

But if i try this in grafana, i only get some strange results like this:


I think, this is the right way, but as you can see it’s not :wink:
Query looks like this:

SELECT field(value) sum() math (/1000)
group by: time(1d) fill (null)

(Sorry, cant add another image)

Any i didn’t add the cost calculation as i don’t know how that’s done (like multiply it by 0.22 for example to get the cost for that day)

Well, any hints are very welcome right know. Maybe im off to a wrong path here, so please point me to the right direction :slight_smile:

Thanks in advance!