Forum Discussion
Rolling Date Identifiers
- 7 months ago
1) Create a WeekStart column in your Date table (Monday-start example):
WeekStart = 'Date'[Date] - WEEKDAY('Date'[Date], 2) + 12) Then create a RollingWeekIndex (1–5) measure (or calculated column if you truly need it stored):
RollingWeekIndex = VAR CurrentWeekStart = MAX ( 'Date'[WeekStart] ) VAR LatestWeekStart = CALCULATE ( MAX ( 'Date'[WeekStart] ), ALL ( 'Date' ) ) VAR DiffWeeks = DATEDIFF ( CurrentWeekStart, LatestWeekStart, WEEK ) RETURN IF ( DiffWeeks >= 0 && DiffWeeks <= 4, 5 - DiffWeeks ) - 7 months ago
hi zedsdead ,
Not sure if i fully get you, try to write a calculated column like:
Column = VAR _DateCurrent = TODAY() // VAR _DateCurrent = DATE(2026, 2, 9) VAR _MondayCurrent = _DateCurrent - WEEKDAY(_DateCurrent, 3) VAR _WeekShift = DATEDIFF(DATE(2025,12,22), TODAY(), WEEK) VAR _result = _WeekShift - DATEDIFF([date], _MondayCurrent, WEEK) +1 RETURN _resultit works like below:
you may comment line 2 and uncomment line 3 to try future dates, like next week:
Hi zedsdead,
I am not entirely certain, but for this type of dynamic comparison between weeks, what usually works very well is to create a “Week Index” logic that adjusts itself automatically as the calendar moves forward.
From your description, your requirements are:
-
You always work with a 5‑week rolling window.
-
Each of those 5 weeks must be assigned a label from 1 to 5, where:
-
1 = oldest week in the current 5‑week window
-
5 = most recent week in the current 5‑week window
-
-
When a new week is added, every existing week “shifts” its index.
That´s it ?
My suggestion is to create a measure that calculates, for each week, which index (1–5) it should have based on the most recent week present in the data.
- A “week ending” date (e.g. every Friday or Sunday),
- Or a week number plus year (e.g. ISO week).
VAR LatestWeek =
CALCULATE(
MAX('Data'[WeekEnding]),
ALL('Data')
)
VAR ThisWeek =
SELECTEDVALUE('Data'[WeekEnding])
RETURN
IF(
NOT ISBLANK(ThisWeek),
5 - DATEDIFF(ThisWeek, LatestWeek, WEEK)
)