cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AMAN560
Frequent Visitor

Soring a matrix in descending order of one column

Hello,

 I have a matrix which is as follows: where field settings are:-   
Rows: Column A and Column B
Values: Column C

 

Metrix
Column  AColumn BColumn C
1125212
 127667
 265213
 876253
2127365
 458112
 768799
 123612
 863265

 

I want to sort this by column C in descending order like this:

 

Column  AColumn BColumn C
1265299
 127667
 876253
 125212
2768798
 863266
 127365
 123612
 458112

 

Bus if I sort matrix by column C here is what i get: 

 

Column  AColumn BColumn C
2768798
 863266
 127365
 123612
 458112
1265299
 127667
 876253
 125212

 

I am getting this result because of the matrix is sorting based on the sum of total COlumn C for each Column A. Since the sum of Column C( for Column A=1) is 231 and the sum of Column C (for column A=2) is 253.

 

Is it possible to sort the matrix accordingly

 

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @AMAN560 

actually, sum of Column C( for Column A=1) is 145 NOT 231 in your sample data.

vxiaotang_0-1628067162683.png

by the way, I want to confirm that, 

vxiaotang_1-1628067740458.png

however, it's little messy to understand, just tell me the value you want to sort , e.g. you want to sort A by ASC and C by DESC. 

 

 

Best Regards,

Community Support Team _Tang

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

Mohammad_Refaei
Solution Specialist
Solution Specialist

I am not aware of any straightforward approach to do this since you want  to have something like the custom sort in Excel.

I would create a new calculation dependent on the values of the two columns and esnure that column A values will always be higher if it has the value 1.

 

Something like:

 

SortingField =
IF (
    [Column A] = 1,
    [Column A] * 1000000 + [Column C],
    [Column A] + [Column C]
)

 

Add this measure to the matrix and make it almost invisible (very narrow) and use it for sorting.

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors