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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
lawada
Helper III
Helper III

sort weeks by dates in the calendar

hello ,

im  trying to create a column that sorts weeks according to dates rather than week name. 

ex. w1 2022 would be : january1-2022 till january7-2022

w2 would be be january8-2022 till january14-2022

w3 woud be  january15-2022 till  january21-2022 

where W1 should always be first 7 days of the begining of the year

 

i was trying to use weeknum function but its sorting weeks according to weekdays from Sunday till Saturday

 

1 ACCEPTED SOLUTION

@lawada , Try columns like

 

Week No =
Var _start = date(Year([Date]),1,1)
return
quotient(datediff(_start,[Date],day) ,7)+1

 

Week Year = Year([Date])*100 + [Week No]

 

Week Start Date = date(Year([Date]),1,1) + ([Week NO]-1) * 7

if(isfiltered('Table Name'[Column name]), Selectedvalue('Table Name'[Column name]), "All")

 

Week That Resets Yearly
https://community.powerbi.com/t5/Community-Blog/Week-That-Resets-Yearly-Decoding-Date-and-Calendar-3...

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

3 REPLIES 3
ValtteriN
Super User
Super User

Hi,

WEEKNUM accepts second parameter where you can define the start date of the week. I recommend cheking this documentation about the function: https://docs.microsoft.com/en-US/dax/weeknum-function-dax

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




the documentation explains the sorting according to weekdays as well. im trying to do something different and sort by dates in the calender as the example i mentiond . any solution for that ?

@lawada , Try columns like

 

Week No =
Var _start = date(Year([Date]),1,1)
return
quotient(datediff(_start,[Date],day) ,7)+1

 

Week Year = Year([Date])*100 + [Week No]

 

Week Start Date = date(Year([Date]),1,1) + ([Week NO]-1) * 7

if(isfiltered('Table Name'[Column name]), Selectedvalue('Table Name'[Column name]), "All")

 

Week That Resets Yearly
https://community.powerbi.com/t5/Community-Blog/Week-That-Resets-Yearly-Decoding-Date-and-Calendar-3...

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.