voosa
October 5, 2023, 8:24am
1
Hi everyone,
i am trying to migrate my influxdb1 statements to influxdb2 with flux. But i have problems to get the same result like the old one. Hope u can help
this is the old statement
SELECT difference(last(“value”)) FROM “smartmeter.0.1-0:1_8_0__255.value” WHERE $timeFilter GROUP BY time(24h) fill(null)
bucket: “iobroker”
i tried a few statements but its not working like before.
BR
Ben
could you please explain your query in simple sentences what you want to achieve using the query?
voosa
October 5, 2023, 8:40am
3
sure . i have a simple value in the database. Its the Energy Counter. Its just an increasing value so i need the difference group by 24 hours. So that i have the increase for a day.
voosa
October 5, 2023, 9:47am
4
finally it works! try and error
from(bucket: “iobroker”)
|> range(start: -360d, stop: now())
|> filter(fn: (r) => r[“_measurement”] == “smartmeter.0.1-0:1_8_0__255”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: 24h, fn: last, createEmpty: false)
|> difference(columns: [“_value”])
|> group(columns: [“_time($interval)”], mode: “by”)
|> fill(column: “_value”, usePrevious: true)
|> sort(columns: [“_time”], desc: true)
thx anyway