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
patrickessa
Regular Visitor

Custom week of month in date table

Hello, I've created a date table in an attempt to create a Year/Month/Week/Date Hierarchy. The problem I have is with the weeks, of course...

 

In every other Q&A that I've studied on the forum, the solution works on the framework of days-of-the-week, i.e. Sunday through Saturday, or Monday through Sunday. 

 

But I need a week number column based on the day of the month (i.e. take whichever number it is, 1-31, divided by 7 days in a week, to give a result somewhere between 1-5). For example, days 1-7 would always give a result = 1, days 8-14 would always give result = 2, etc.

 

Here's what I mean, the two real columns are the ones I've managed to create, and the far-right column with red text ("WeekNum") is what I actually want a DAX formula to do:

 

Screen Shot 2018-05-14 at 5.30.14 PM.png

 

Thanks in advance!

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @patrickessa

 

Does this do what you want?

 

Column = INT((DAY([Date])-1)/7)+1

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
Phil_Seamark
Employee
Employee

Hi @patrickessa

 

Does this do what you want?

 

Column = INT((DAY([Date])-1)/7)+1

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thanks @Phil_Seamark

PS, don't try and create a YEAR/MONTH/WEEK hierarchy.  They just don't work well together.

 

Create a YEAR/MONTH, or a YEAR/WEEK - but in the later case make sure the YEAR aligns with your first/last weeks


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.