Forum Discussion
How to Sort Data in Power BI Matrix by Multiple Conditions
I have raw data as follows
Then I use power bi and use Matrix to drag the table as follows. However, I want to sort by the following 2 conditions:
1. Sort by year from smallest to largest
2. In each year, revenue by product is sorted from largest to smallest revenue.
I can only sort by 1 condition, I cannot combine both conditions.
This is the result I want
Please help me!
Matrix can only be sorted either by value or by category. In your case, you can sort by the field in the second level of the row hierarchy.
2 Replies
- danextianSuper User
Matrix can only be sorted either by value or by category. In your case, you can sort by the field in the second level of the row hierarchy.
- JustSayJoeAdvocate IV
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.