Hello,
I would like to display values from a gas meter.
The reading is always ascending, the value is always increasing.
I would therefore have to display one counter per day from the first value to the last value and I would like to do this for the last X days.
How must this look in Flux?
Thanks a lot.
from(bucket: "iobrokerMZ")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "javascript.0.gaszaehlerStand")
|> filter(fn: (r) => r["_field"] == "value")
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: "last")
Maybe this query can do the job:
from(bucket: "iobrokerMZ")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "javascript.0.gaszaehlerStand")
|> filter(fn: (r) => r["_field"] == "value")
|> group()
|> aggregateWindow(1d, fn: count, createEmpty: false)
|> yield(name: "count")
Changes from original query are:
-
group()
- will group all your data into a single table
-
aggregateWindow(every: 1d, fn: count, createEmpty: false)
- this will aggregate and count data per day
2 Likes
Hello,
Thank you for your answer.
I think I have a logical error in my thoughts.
I have a value that keeps increasing from measurement to measurement.
What do I have to tell the database to give me the value of a day, the value is the difference between the first value of a day and the last value of a day.
However, the last value of the previous day can also be the first value of the next day.
Thanks for your help.