Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
zedsdead
Regular Visitor

Rolling Date Identifiers

I support a team monitoring weekly captured data from a 5 week window. Each row of my set has a specific date - thousands of rows of data fitting into 5 weeks, and my report needs to dynamically compare each week's data with the others. I'm working to prep DAX to assign number 1-5 to each of the weeks as the project rolls on.

 

So currently: Dec 22 = 1, Dec 29 = 2, Jan 5 =3, Jan 12 = 4, Jan 19 = 5. 

Next week: Dec 29 = 1, Jan 5 = 2, Jan 12 = 3, Jan 19 = 4, Jan 26 = 5 and so on..

 

First time in the forums so please let me know if I need to provide additional context. 

2 ACCEPTED SOLUTIONS
cengizhanarslan
Super User
Super User

1) Create a WeekStart column in your Date table (Monday-start example):

WeekStart =
'Date'[Date] - WEEKDAY('Date'[Date], 2) + 1

 

2) 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 )

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

View solution in original post

FreemanZ
Community Champion
Community Champion

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 _result

 

it works like below:

FreemanZ_0-1769500877842.png

 

you may comment line 2 and uncomment line 3 to try future dates, like next week:

FreemanZ_1-1769500980848.png

 

View solution in original post

6 REPLIES 6
v-ssriganesh
Community Support
Community Support

Hello @zedsdead,

Hope everything’s going great with you. Just checking in has the issue been resolved or are you still running into problems? Sharing an update can really help others facing the same thing.

Thank you.

v-ssriganesh
Community Support
Community Support

Hello @zedsdead,
Thank you for posting your query in the Microsoft Fabric Community Forum, and thanks to @FreemanZ@cengizhanarslan & @Zanqueta for sharing valuable insights.

 

Could you please confirm if your query has been resolved by the provided solutions? This would be helpful for other members who may encounter similar issues.

 

Thank you for being part of the Microsoft Fabric Community.

thank you team for all of the responses! I'm still working through the solution and will mark as resolved asap. 

FreemanZ
Community Champion
Community Champion

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 _result

 

it works like below:

FreemanZ_0-1769500877842.png

 

you may comment line 2 and uncomment line 3 to try future dates, like next week:

FreemanZ_1-1769500980848.png

 

cengizhanarslan
Super User
Super User

1) Create a WeekStart column in your Date table (Monday-start example):

WeekStart =
'Date'[Date] - WEEKDAY('Date'[Date], 2) + 1

 

2) 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 )

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.
Zanqueta
Super User
Super User

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.

 

Ideally, you should have a Date/Calendar table and, within it, a column that represents the week. Typical options include:
  • A “week ending” date (e.g. every Friday or Sunday),
  • Or a week number plus year (e.g. ISO week).
For the sake of the example, let us assume you have:
 
'Data'[WeekEnding]
 
This is a date representing the end of each week (for example, every Friday).
 
WeekIndex measure:
WeekIndex :=
VAR LatestWeek =
CALCULATE(
MAX('Data'[WeekEnding]),
ALL('Data')
)
VAR ThisWeek =
SELECTEDVALUE('Data'[WeekEnding])
RETURN
IF(
NOT ISBLANK(ThisWeek),
5 - DATEDIFF(ThisWeek, LatestWeek, WEEK)
)

 

If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.