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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
abukapsoun
Post Patron
Post Patron

Sorting based on last column

Hi Guys,

 

Need your support please.

I have the following matrix, How can I sort the table from largest to smallest based on last day values?

 

abukapsoun_0-1668511385932.png

 

Thank you

 

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @abukapsoun 

 

This is my test table:

vyadongfmsft_0-1669181237373.png

 

Please create a measure:

 

Measure = 
var _maxdate=MAXX(ALLSELECTED('Table'),[Date])
var _sum= CALCULATE(SUM('Table'[Value]),FILTER('Table',[Date]=_maxdate))
return
IF(HASONEVALUE('Table'[Date]),SUM('Table'[Value]),_sum)

 

 

Create a matrix visual. The column subtotals will become the last day value as below shown, then you can sort from largest to smallest based on last day values:

vyadongfmsft_1-1669181466020.png

 

If you don't want to show column subtotals, you can switch off column subtotals after sorting.

vyadongfmsft_2-1669181685665.png

 

Best regards,

Yadong Fang

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

3 REPLIES 3
v-yadongf-msft
Community Support
Community Support

Hi @abukapsoun 

 

This is my test table:

vyadongfmsft_0-1669181237373.png

 

Please create a measure:

 

Measure = 
var _maxdate=MAXX(ALLSELECTED('Table'),[Date])
var _sum= CALCULATE(SUM('Table'[Value]),FILTER('Table',[Date]=_maxdate))
return
IF(HASONEVALUE('Table'[Date]),SUM('Table'[Value]),_sum)

 

 

Create a matrix visual. The column subtotals will become the last day value as below shown, then you can sort from largest to smallest based on last day values:

vyadongfmsft_1-1669181466020.png

 

If you don't want to show column subtotals, you can switch off column subtotals after sorting.

vyadongfmsft_2-1669181685665.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello, for this measure, if last column has no value then it takes value from previous column. How to adjust measure so if there is no value , there is no value?

mangaus1111
Solution Sage
Solution Sage

Hi @abukapsoun ,

I think that it is not possible to sort a column in a matrix, but it is possible to sort a measure in a matrix. You have to find the way to create a measure only for the last day.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.