I have Total KWh every day, need display KWh/day

i have sensor that append the total KWh every hour to influxDB

SELECT last(“value”) FROM “energy” WHERE (“id” =~ /^id/) AND $timeFilter GROUP BY time(1d)

this give me the total accumulated value everyday

i need to substact the yesterday value to get the consumption of the day… Im unable to do that.
Can someone help me?

I need to see total consumption by Day

todayKwh = today(last) - yesterday(last)

Capturarg

Hi @daeynasvistas,

can you describe what your raw data looks like a bit more? What are the values that your sensor is transmitting? Do the values always go up over time?

If I understand it correctly based on

todayKwh = today(last) - yesterday(last)

the solution is something like

SELECT difference(last("value")) FROM "energy" WHERE ("id" =~ /^id/) AND $timeFilter GROUP BY time(1d)

An additional offset parameter for the time() grouping may be necessary to get the date boundaries to be correct.

(off topic: any idea why the formatting of text between three backticks looks so funny?)