Need help. Influxdb1 vs. influxdb2 with flux

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. :frowning: Hope u can help :slight_smile:

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. :frowning:

BR

Ben

could you please explain your query in simple sentences what you want to achieve using the query?

sure :slight_smile: . 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.

finally it works! try and error :slight_smile:

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