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
rhashhab
Frequent Visitor

How to get Week Ranges in Power BI ?

Hi Power BI Community,

I need to get week ranges like this way :

1Jan-8Jan 

9Jan-16Jan

17Jan-24Jan

25Jan-31Jan ( If it's until 30th of Jan then get me until 30th) 

 

How to write this kind of DAX formula considering 30th and 31th case?

I want it for each month like this way without weeks interfering from 1 month with another month

 

1 ACCEPTED SOLUTION

something like this?

FreemanZ_0-1668944547554.png

WeekNumber =
VAR _day = DAY(Data[Date])
RETURN
SWITCH(
    TRUE,
    _day >= 1 && _day <= 8, "1-8",
    _day >= 9 && _day <= 16, "9-16",
    _day >= 17 && _day <= 24, "17-24",
     "24 onwards"
     )

View solution in original post

6 REPLIES 6
rhashhab
Frequent Visitor

@FreemanZ 

Week Number

1Jan-8Jan 

9Jan-16Jan

17Jan-24Jan

25Jan-31Jan ( If it's until 30th of Jan then get me until 30th) 

 

something like this?

FreemanZ_0-1668944547554.png

WeekNumber =
VAR _day = DAY(Data[Date])
RETURN
SWITCH(
    TRUE,
    _day >= 1 && _day <= 8, "1-8",
    _day >= 9 && _day <= 16, "9-16",
    _day >= 17 && _day <= 24, "17-24",
     "24 onwards"
     )

Thank you so much for your help @FreemanZ  !

FreemanZ
Super User
Super User

you may create a new column with WEEKNUM function, then refer to the added column in your new measures or visuals.

 

About WEEKNUM

https://learn.microsoft.com/en-us/dax/weeknum-function-dax

@FreemanZ  I don't want to use week number. I want date to be the same format I mentioned above.

could you depict your expected result with a table?

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.