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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ericbi
Frequent Visitor

How to sort weeknumber in row?

Hi, 

 

I have table like this 

1.JPG
I would like to have a visualization table like this and the top row sorted by weeknum descending. but BI always sort it ascending. I checked lot of topic but can't find a solution.  the weeknum is in whole number format. 

2.JPG

Thank you. 

1 ACCEPTED SOLUTION

I found that I can sort it in the report after I submitted to the web.  just go to that visualization at right corner and select sort by weeknumber then done.  it's not working in desktop. 

 

thank you everyone. 

View solution in original post

6 REPLIES 6
ccakjcrx
Resolver I
Resolver I

Hey @ericbi!

 

I put your data into an Excel sheet--not power pivot. I then imported the excel sheet into power bi. I then created a matrix with the info, and it appeared as follows by default:

 

Screenshot.jpg

 

 

 

 

 

 

 

 

 

Click HERE if you need to access my .pbix file. 

Hi, 

 

I would like to have the 201803 in the first column, then 201802... etc.  

Anonymous
Not applicable

@ericbi,

Please follow the steps below.

1. Create a conditional column in Query Editor of Power BI Desktop.
1.JPG

2. In report view of Power BI Desktop, click the Week column in your tables, then choose "Sort by column" to sort the Week column by the Custom column(conditional column).
2.JPG

Regards,
Lydia

Thank you Lydia. but my report has scheduled refresh,  so the weeknumber will be added automatically, I would like to find a way to sort it by itself.  

 

thanks again. 

Anonymous
Not applicable

Credits to @ipsingh79 in an earlier forum post. I checked his solution and that works:

 

Please check if all weeks are correctly filled like 201801, 201818, etc. This must be correct to let the solution work.

Open Edit Query --> Add custom column as : SortWeek = 999953 - [Week]

Apply and Close the query editor

Sort the original Week column with the custom column "SortWeek"

 

Matrix will be correctly sorted (201803 as first column)

I found that I can sort it in the report after I submitted to the web.  just go to that visualization at right corner and select sort by weeknumber then done.  it's not working in desktop. 

 

thank you everyone. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Users online (1,964)