Forum Discussion
Matrix multiple Sort columns
- 7 years ago
You may try using ISONORAFTER Function to add a measure.
Measure = VAR e = SELECTEDVALUE ( Table1[Employee] ) VAR c = [TotalCount] VAR t = SUMMARIZE ( ALLSELECTED ( Table1 ), Table1[Employee], Table1[Customer] ) RETURN COUNTROWS ( FILTER ( t, ISONORAFTER ( Table1[Employee], e, DESC, [TotalCount], c, ASC ) ) )
If you have the latest version of PowerBI desktop you can do this in 4 following steps:
Step 1: Convert the matrix into a table
Step 2: Sort the table by "Employee" column (Click again if you want to change the sorting order in opposite direction)
Step 3: Now add additional sort in the table by using Shift + Lift Click on "TotalCount " column (Shift + Lift Click again to change sort order to opposite direction)
Step 4: Convert the table back to matrix now, and your matrix retain these sort orders now
If this helps you then please give a thumbs up to the solution
This works well when the matrix only has one row.
But if it has two rows, aka hierarchy matrix, this doesn't work.
- JustSayJoe3 years agoAdvocate IV
You can maintain multiple levels of the hierarchy by converting your Matrix to a Table, then removing your sub-level of the hierarchy from the table, do the multiple sort by steps in the table, convert the table back to a matrix, and finally add back in the sub-level of the hierarchy to the rows of the matrix. This should maintain the sort by order for multiple levels of the row hierarchy.
** Updated the steps for clarity (3/28/2025) **
Step 1: In your Matrix, add a field to the row hierarchy (which you will later remove).
Step 2: Change the Matrix to a Table visual.
Step 3: Sort all the columns you wish to sort, and in the order you wish them to be sorted.
Step 4: Delete the field you previously added in Step 1 from the table.
Step 5: Change the Table back to a Matrix visual.
Step 6: Ensure the right fields are back in the Row hierarchy.
This will maintain your multiple sorted fields within your matrix, even when you expand your row hierarchies.
- AlexanderKais2 years agoAdvocate I
Plase mark this as Solution. That is absolut genious and easier then a compolex measure 😉
- nglenn13 years agoRegular Visitor
this didn't work for me either
- JenJaRu3 years agoRegular Visitor
wow - thank you! this worked perfectly