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
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
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.