Hello,
I have this code and get this result:
import "timezone"
import "date"
option location = timezone.location(name: "Europe/Vienna")
startExt = date.sub(d: 6mo, from: v.timeRangeStop)
from(bucket: "bucketA")
|> range(start: startExt, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "Haus")
|> filter(fn: (r) => r.Bereich == "Pellets")
|> filter(fn: (r) => r.Sensor == "Status")
|> filter(fn: (r) => r._field == "Resetierbarer_kg-Z_hler___kg_")
|> aggregateWindow(every: duration(v: "${per}"), fn: last, createEmpty: true)
|> timeShift(duration: -1s, columns: ["_time"])
|> difference(nonNegative: true, columns: ["_value"])
|> yield(name: "last")
The issue:
When ${per} = 1w, the query shows 121 kg for the current week (KW 43).
But today is Monday, the first day of the week — the real value should be only around 12 kg.
If I switch ${per} to 1d, the daily value looks correct (12 kg).
In Grafana, my week start is already set to Monday.
So my questions are:
-
Does 1w in Flux mean “7 days from now” rather than a calendar week (Mon–Sun)?
-
Is the current, unfinished week being ignored or merged with the previous one?
-
How can I make the aggregation follow real calendar weeks (Mon–Sun)?
Thanks for your help!


