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](https://us1.discourse-cdn.com/grafana/original/2X/e/e7637d924b413947e327eb042b4f065393ed0012.png)
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?
svetb
3
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?)