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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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

6 REPLIES 6
thescooble
New Member

 why is it this method sorts from left to right when the rank column isn't even used or refereed to in the matrix?.

Because they used the "sort by column" option which happens in the background but affects the visual.

 

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors