Forum Discussion
sorting matrix
- 9 months ago
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:
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
- Click on the ellipsis (…) in the top-right corner of your Matrix visual.
- Select Sort by → Year.
- Then click the ellipsis (…) again and choose Sort by → Value.
Power BI will apply sorting hierarchically within the Matrix, starting from the outer field (Country → Year → Value).
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