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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Selded
Helper III
Helper III

Custom week per month

I have a date table with week number based on the calender year. Each week starts from monday and ends on sunday. I want to create a custom week number based on months, each month will have week1, 2, 3,4,5.

 

Below is a sample of my date table. 

 

Selded_0-1597750109611.png

 

Thanks for the assistance.

3 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Selded , Try new columns like. You might have some the dependent colums with different name

 

Start Month = STARTOMONTH('Date'[Date])
WeekDay = WEEKDAY([Date],2) //monday
Start of Week = [Date] -[WeekDay]+1 //monday
Month Week = QUOTIENT(DATEDIFF(Minx(FILTER('Date',[Start Month]=EARLIER([Start Month])),'Date'[Start of Week]),[Date],DAY),7)+1

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

vanessafvg
Super User
Super User

in power query under transform ribbon bar, select  date (has a calendar looking thing) drop down to  week from the menu and you should be able to choose week of month there, duplicate your date column before you do this.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

@vanessafvg 

 

This worked , but unfortuantely my date table has week day starting on monday instead of Sunday. how do i edit the start day of my week to get this sorted correctly.

View solution in original post

7 REPLIES 7
vanessafvg
Super User
Super User

in power query under transform ribbon bar, select  date (has a calendar looking thing) drop down to  week from the menu and you should be able to choose week of month there, duplicate your date column before you do this.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




@vanessafvg 

 

This worked , but unfortuantely my date table has week day starting on monday instead of Sunday. how do i edit the start day of my week to get this sorted correctly.

here is good article explaining how to adjust that There is a function called StartOfWeek that displays the start of the week in Power Query formula language.

Syntax: Date.StartOfWeek(<date>)

The week starts on Sunday and runs through to Saturday. To use Monday to Friday, you can add a day to it using the function Date.AddDays(<date>, 1).

https://carldesouza.com/power-query-language-m-start-week/

then you can write code in the custom column to adjust things the way you want to...




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




@vanessafvg @amitchandak 

 

Thank you both, i got the week numbers correctly. 

 

please is there a way to for the column to read week 1 , week 2, instead of 1,2, 3.

 

Selded_0-1597755618211.png

 

Thank you 

just create a new column concatenating"week" + week no.




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




amitchandak
Super User
Super User

@Selded , Try new columns like. You might have some the dependent colums with different name

 

Start Month = STARTOMONTH('Date'[Date])
WeekDay = WEEKDAY([Date],2) //monday
Start of Week = [Date] -[WeekDay]+1 //monday
Month Week = QUOTIENT(DATEDIFF(Minx(FILTER('Date',[Start Month]=EARLIER([Start Month])),'Date'[Start of Week]),[Date],DAY),7)+1

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak 

 

Thanks, this fixes the issue.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.