Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tbobolz
Resolver I
Resolver I

How to Sort (Left to Right) descending by column totals in a matrix.

Hi All,

I've search and read tons but can find how to do this. Everything is about sorting on the row or column header or row totals, not the column total values. I'd like to sort the below matrix from highest column total to lowest, left to right. Hard to explain, so here is a picture. Is this possible?

Thanks for any help you can offer. 

Terry

 

Capture.PNG 

1 ACCEPTED SOLUTION

Hi, @tbobolz 

You can take a try follow steps:

1.calculate the 'Total' directly in fact table

Total = CALCULATE(SUM('Table'[Rxxxx]),ALLEXCEPT('Table','Table'[Hospital]))

2. Create 'Rank' column based on 'Total' filed

Rank = RANKX('Table','Table'[Total],,DESC,Dense) //or asc

3.duplicate your original column 'Hospital'

Hospital_2 = 'Table'[Hospital] 

Then sort this new column by calculated column 'Rank'

190.png

4. replace your original field 'Hospital' with new field 'Hospital_2' in matrix visual

192.png

Please check my sample file for more details.

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

I don't think this is currently possible, at least not where it dynamically resorts depending on slicers/filters.

 

I could be wrong (someone please correct me if I am) but I can't think of a way to do this other than hacky workarounds.

Thanks, that's what I'm thinking too.

Hi, @tbobolz 

You can take a try follow steps:

1.calculate the 'Total' directly in fact table

Total = CALCULATE(SUM('Table'[Rxxxx]),ALLEXCEPT('Table','Table'[Hospital]))

2. Create 'Rank' column based on 'Total' filed

Rank = RANKX('Table','Table'[Total],,DESC,Dense) //or asc

3.duplicate your original column 'Hospital'

Hospital_2 = 'Table'[Hospital] 

Then sort this new column by calculated column 'Rank'

190.png

4. replace your original field 'Hospital' with new field 'Hospital_2' in matrix visual

192.png

Please check my sample file for more details.

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This approach works as long as that the ranking is fixed. If filters or slicers are applied to the visual, there's no guarantee that this pre-calculated ranking is still accurate.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.