Forum Discussion
How to Sort by Column on a Matrix Visual
- 1 year ago
Hi abraine
Since Power BI does not allow direct sorting of columns in a Matrix, follow these steps:
Option 1: Create a Sort Order Column using RANKX- In Power BI Desktop, go to Data View.
- Open the table containing your date column.
- Create a new calculated column in DAX:
- DAX
SortOrder = RANKX(
ALL('YourTable'[DateColumn]),
'YourTable'[DateColumn],
,
DESC, -- Sort from most recent to oldest
DENSE -- Ensures continuous ranking
) - In Modeling → Sort by Column, select DateColumn and sort it by SortOrder.
Option 2: Use "Sort by Column" in the Modeling Tab
- If your table has a "Week Ending" or "Date" column, make sure it's formatted as a date.
- Go to Modeling → Click the DateColumn.
- Select Sort by Column → Choose DateColumn (or a numeric sort column if created).
- The matrix should now display columns in descending order (most recent first).
Note: If your date hierarchy is enabled in the matrix, try removing the hierarchy and using the raw date column.
If this response was helpful, please accept it as a solution and give kudos to support other community members
Hi abraine
Since Power BI does not allow direct sorting of columns in a Matrix, follow these steps:
Option 1: Create a Sort Order Column using RANKX
- In Power BI Desktop, go to Data View.
- Open the table containing your date column.
- Create a new calculated column in DAX:
- DAX
SortOrder = RANKX(
ALL('YourTable'[DateColumn]),
'YourTable'[DateColumn],
,
DESC, -- Sort from most recent to oldest
DENSE -- Ensures continuous ranking
) - In Modeling → Sort by Column, select DateColumn and sort it by SortOrder.
Option 2: Use "Sort by Column" in the Modeling Tab
- If your table has a "Week Ending" or "Date" column, make sure it's formatted as a date.
- Go to Modeling → Click the DateColumn.
- Select Sort by Column → Choose DateColumn (or a numeric sort column if created).
- The matrix should now display columns in descending order (most recent first).
Note: If your date hierarchy is enabled in the matrix, try removing the hierarchy and using the raw date column.
If this response was helpful, please accept it as a solution and give kudos to support other community members