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
Uzi2019
Super User
Super User

Calculate Start week always from 1st day of month

Hi experts,

I want to calculate start week and end week but there is condition I have attached a screen shot.( Week should always be start from 1st day of the month )

I want to calculate 3 different measure "Start week", "End week" and "No of days".

 

Uzi2019_0-1603197742774.png

I want above mentioned result.

 

Please guys I need it on urgent basis. Any help would be appreciated.

 

Thank You in Advance.

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Uzi2019 , You can get the start or week like

 

Start Month = STARTOMONTH('Date'[Date])
Month Week Start = [Start Month] + QUOTIENT(datediff([Start Month],[date],day),7) *7

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Uzi2019 , You can get the start or week like

 

Start Month = STARTOMONTH('Date'[Date])
Month Week Start = [Start Month] + QUOTIENT(datediff([Start Month],[date],day),7) *7

@amitchandak  Thank you so much Start week is working now. 

Could you please also share the EndWeek like I mentioned in Screen shot.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

@Uzi2019 , Try like

Month Week end = if( [Month Week Start]+7 <= eomonth([Month Week Start] ,0),[Month Week Start]+7 ,eomonth([Month Week Start] ,0))

@amitchandak ,

Start Week = STARTOFMONTH(TableDate]) + QUOTIENT(DATEDIFF(STARTOFMONTH(Table[Date]),Table[Date],DAY),7)*7
End Week = IF(Table[Start Week]+6<=EOMONTH(Table[Start Week],0),Table[Start Week]+6,EOMONTH(Table[Start Week],0))
 
I just did minor changes in End Week Column suggested by. i.e. replace 7 with 6 so now its properly ending with 7th of Month as End week.
 
Thanks a bunch for your quick response and workable solution. 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

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.