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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Sfns_2024s
New Member

How do I specify certain date as the first week and calculate the week number in dax

How do I get the week number based on the date that I set as first week ? For example 2023-05-21 should be Week 1 instead of 2023-01-01

 

Thanks,

1 ACCEPTED SOLUTION
v-jialongy-msft
Community Support
Community Support

Hi @Sfns_2024s 

 

Try the following dax

Custom Week Number = 
VAR CustomStartDate = DATE(2023, 5, 21)
VAR CurrentDate = 'Table'[Date]  .[Date]
VAR DaysDiff = CurrentDate - CustomStartDate
VAR WeeksFromCustomStart = INT(DaysDiff / 7)
RETURN IF(DaysDiff < 0, BLANK(), WeeksFromCustomStart + 1)

vjialongymsft_0-1709536925265.png

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-jialongy-msft
Community Support
Community Support

Hi @Sfns_2024s 

 

Try the following dax

Custom Week Number = 
VAR CustomStartDate = DATE(2023, 5, 21)
VAR CurrentDate = 'Table'[Date]  .[Date]
VAR DaysDiff = CurrentDate - CustomStartDate
VAR WeeksFromCustomStart = INT(DaysDiff / 7)
RETURN IF(DaysDiff < 0, BLANK(), WeeksFromCustomStart + 1)

vjialongymsft_0-1709536925265.png

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

lbendlin
Super User
Super User

Use an external reference table for your calendar where you have the fiscal year or fiscal quarter weeks marked as a dedicated column.  This can be an Excel file on a SharePoint, for example.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors