Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Post Prodigy
Post Prodigy

Sorting year weeks in Power BI



I would like to ask how to properly sort year week because in visual it seems unsorted:

Here is the view of it



Is possible to fix it?

Solution Specialist
Solution Specialist

Hi @Analitika ,


Due to the "-" in the middle of the Year-Week number, that value is stored as text. This is the reason the sorting is not working for you.


In order to sort it correctly, you can replace the Year-Week formula you are currently using with the following:


Year-Week = 
    VAR __Year = Year( [Date] )
    VAR __WeekNum = WEEKNUM( [Date] )

    IF( __WeekNum < 10, CONCATENATE( __Year, "-0" & __WeekNum ), CONCATENATE( __Year, "-" & __WeekNum ))


The difference is the "0" before any single-digit week numbers. This allows the sorting to work correctly.

Did I answer your question? Mark my post as a solution!
My LinkedIn
Solution Sage
Solution Sage


Changed data type as Date and format as below



I am getting this 



Hi @Analitika ,

Please create a new column on your date table like below :

YearWeekIndex = dim_date[Year] * 100 +dim_date[Week of Year]
Then select your YearWeek column, go to sort by column and click on 'YearWeekIndex'. Your yearweek field will now be sorted using this column.


Kind regards,


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 😊

Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors