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
Hello, I would like to sort matrix table by Year and then by value for each Country. How to do it?
Country Year Value
Belarus 2024 19099
Belarus 2025 19023
Belarus 2023 17596
Paraguay 2024 11559
Paraguay 2025 11556
Paraguay 2023 242
Solved! Go to Solution.
@Ania26 Sorry I just took another look at your picture and now I get what your issue is. You're currently sorting by the Value descending but actually want the dimensions ascending, right?
Your current version probably looks similar to this:
Hi @Ania26.,
I would also take a moment to thank @Ilgar_Zarbali , @KarinSzilagyi for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Regards,
Community Support Team.
Hi @KarinSzilagyi,
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We are always here to support you.
Regards,
Community Support team.
In Power BI, the Matrix visual allows you to control sorting on multiple levels, but it behaves slightly differently from a normal table.
If you want to sort by Year (in descending order) and then by Value within each Country, follow these steps:
Option 1 – Sort using the visual menu
Option 2 – Use a calculated sort column
If the sorting still doesn’t display as expected, create a calculated column in your data model:
SortOrder =
RANKX(
FILTER(
'Table',
'Table'[Country] = EARLIER('Table'[Country])
),
'Table'[Value],
,
DESC
)
Option 3 – Sort the Matrix manually
You can also click directly on the column headers (Year or Value) in the Matrix visual.
Power BI lets you click twice to switch between ascending/descending order for that level.
Each Country will appear as a separate group (like Belarus and Paraguay in your screenshot), and inside each group, years will be sorted correctly with the corresponding values.
I hope it will help you. If so, please give kudoes and accept it as a solution. Thanks
Hi @Ania26, I'd just flip the two fields used in "Rows", so you group first by year, then by country:
vs
Hello, thank you but I want to see first Country and then Year
@Ania26 Sorry I just took another look at your picture and now I get what your issue is. You're currently sorting by the Value descending but actually want the dimensions ascending, right?
Your current version probably looks similar to this:
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 33 | |
| 32 | |
| 31 | |
| 26 |
| User | Count |
|---|---|
| 134 | |
| 96 | |
| 78 | |
| 67 | |
| 65 |