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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
kumarp
Regular Visitor

How to derive week in month with Monday to sunday weekly bucket

Hi,

 

Can any one please help me to derive week in month field with Monday to sunday weekly bucket from Date field.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Hi, @kumarp 

According to your description, you want to get the week in every month and the logic is from Monday to Sunday.

Here are the steps you can refer to :
(1)If you want to create a calcualte column, you can use this dax code:

Column 2 = var _date = [Date]
var _first_of_month =  DATE( YEAR(_date) , MONTH(_date) ,1)
var _end_of__month =  EOMONTH(_date,0)
var _t = ADDCOLUMNS( CALENDAR(_first_of_month , _end_of__month) , "WEEK" , WEEKDAY([Date],2))
var _count=COUNTROWS( FILTER(_t , [Date]<_date && [WEEK] = 7))
return
_count+1

 

vyueyunzhmsft_0-1692150447395.png

 

(2)If you want to create a measure , you can use this dax code :

Measure = var _date = MAX('Table'[Date])
var _first_of_month =  DATE( YEAR(_date) , MONTH(_date) ,1)
var _end_of__month =  EOMONTH(_date,0)
var _t = ADDCOLUMNS( CALENDAR(_first_of_month , _end_of__month) , "WEEK" , WEEKDAY([Date],2))
var _count=COUNTROWS( FILTER(_t , [Date]<_date && [WEEK] = 7))
return
_count+1

 

The result is as follows:

vyueyunzhmsft_1-1692150488117.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

4 REPLIES 4
kumarp
Regular Visitor

Hi,

 

Can any one please help me on below requirement. I have derived week in month using below formula but its taking Monday to Sunday bucket. Please help me on this.

 

 

Week in month = 1 + WEEKNUM ( INCOMEDETAILVIEW_MH[Booked Date] )-WEEKNUM( STARTOFMONTH (INCOMEDETAILVIEW_MH[Booked Date]))

 

kumarp_0-1692007877194.png

 

 

Greg_Deckler
Community Champion
Community Champion

@kumarp You can use WEEKNUM([Date], 2) for Monday - Sunday week. From there, you could grab the MIN for the current month and subtract that + 1 from the WEEKNUM value.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

I have tried below but week2 is getting wrong . I am expecting august 7th (Monday) to august 13th (Sunday) as week2 but getting august 13th on week3. Please can you help me on this.

I need to show week in month for all the months.

 

Week in month = 1+WEEKNUM ( INCOMEDETAILVIEW_MH[Booked Date].[Date],2)-WEEKNUM( STARTOFMONTH (INCOMEDETAILVIEW_MH[Booked Date]))

 

kumarp_0-1692022665111.png

 

Hi, @kumarp 

According to your description, you want to get the week in every month and the logic is from Monday to Sunday.

Here are the steps you can refer to :
(1)If you want to create a calcualte column, you can use this dax code:

Column 2 = var _date = [Date]
var _first_of_month =  DATE( YEAR(_date) , MONTH(_date) ,1)
var _end_of__month =  EOMONTH(_date,0)
var _t = ADDCOLUMNS( CALENDAR(_first_of_month , _end_of__month) , "WEEK" , WEEKDAY([Date],2))
var _count=COUNTROWS( FILTER(_t , [Date]<_date && [WEEK] = 7))
return
_count+1

 

vyueyunzhmsft_0-1692150447395.png

 

(2)If you want to create a measure , you can use this dax code :

Measure = var _date = MAX('Table'[Date])
var _first_of_month =  DATE( YEAR(_date) , MONTH(_date) ,1)
var _end_of__month =  EOMONTH(_date,0)
var _t = ADDCOLUMNS( CALENDAR(_first_of_month , _end_of__month) , "WEEK" , WEEKDAY([Date],2))
var _count=COUNTROWS( FILTER(_t , [Date]<_date && [WEEK] = 7))
return
_count+1

 

The result is as follows:

vyueyunzhmsft_1-1692150488117.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors