Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
This is a popular topic on the boards, I know, and I've read many different solutions, however nothing seems to be working for me and it's got me stumped.
My matrix has a Date Hierachy for columns. It's 8 years of columns, so I'd like the most recent year leftmost in the table. I added a RANK() line to my SQL query:
RANK() over(order by Skus.EventDate DESC) as DateSortwhich gives the most recent date a value of 1, and so on. Based on this column I then used the Sort By Column (sort EventDate by DateSort). It all looks fine in the Data view (although - is there supposed to be a check mark beside the column selected as the sort by? Mine doesn't show a checkmark....)
Going back to look at my matrix, it hasn't done anything - old year is still leftmost. What am I missing?
Solved! Go to Solution.
Hi, @a68tbird ;
I tested it , product as rows, sales as values, date as column;
If the column is Date Hierarchy, sort by column is not work ,so we should change the different column about year and month.
create a rank column.
Column =RANKX('financials',YEAR('financials'[Date]),,DESC,Dense)
The final output is shown below:
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @a68tbird ;
I tested it , product as rows, sales as values, date as column;
If the column is Date Hierarchy, sort by column is not work ,so we should change the different column about year and month.
create a rank column.
Column =RANKX('financials',YEAR('financials'[Date]),,DESC,Dense)
The final output is shown below:
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Everything that I'm reading, seems to suggest that this should work. I decided to create a brand new report, new sample data, and try it again from scratch. With my data imported, I created two calculated columns:
DateSort = sampleData[RecognitionDate].[Date]Rank = RANKX(sampleData,sampleData[RecognitionDate],,,Skip)
I then sorted the DateSort date by Rank. This displays correctly in the Data view (most recent sales date is ranked 1). I then add three fields to a matrix: Products as Row, StoreTotal as Value and DateSort as Columns. The matrix still has oldest year leftmost in the grid.
I've followed a suggestion from this post: Solved: Sort date field in Matrix column header descending - Microsoft Power BI Community but it's not working for me. Does the fact that I'm using a Date Hierachy in the matrix make a difference?
@a68tbird no, it doesn't show the checkmark but highlights the sorted by column and in your case, it looks ok.
Can you click on the top right corner 3 dots on the matrix visual and make sure the correct column is used for sorting.
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
EventDate doesn't show as an option there in the Sort By. I thought that was the whole issue with the "sort by column headers". By default PowerBI sorts the date by ASC, and columns don't appear in the matrix visual sort by options.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 133 | |
| 88 | |
| 85 | |
| 68 | |
| 64 |