Convert SELECT with integral from InfluxQL to Flux statement

I’m migrating from v1.8 with InfluxQL to v2.6.1 with Flux.

On v1.8 I’m using the following query to show the integral of the delivered daily power from my solar converter:

SELECT integral(“value”,1h) FROM “LeistungDach” WHERE $timeFilter GROUP BY time(1d)

The $timeFilter comes from the calling Grafana and is equal to the range of the last 7 days. (e.g. range(start: v.timeRangeStart, stop:v.timeRangeStop))

So I get the integral over complete day data separated by day of the last 7 days.

But how to migrate the rest of the SELECT? TBH I’m not able to migrate it to a flux statement. :pensive:

Can anyone please help?

Once again, I found the solution by myself. Maybe it helps other users:

//SELECT integral(“value”,1h) FROM “LeistungDach” WHERE $timeFilter GROUP BY time(1d)
import “experimental”
import “date”

from(bucket: “iobroker”)
|> range(start: -7d, stop: now())
|> filter(fn: (r) =>
r._measurement == “LeistungDach” and
r._field == “value”)
|> window(every: 1d)
|> integral(unit: 1h)
|> group(columns: [“_time”])