cancel
Showing results for
Search instead for
Did you mean:
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  A Column B Column C 1 1252 12 1276 67 2652 13 8762 53 2 1273 65 4581 12 7687 99 1236 12 8632 65

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

 Column  A Column B Column C 1 2652 99 1276 67 8762 53 1252 12 2 7687 98 8632 66 1273 65 1236 12 4581 12

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

 Column  A Column B Column C 2 7687 98 8632 66 1273 65 1236 12 4581 12 1 2652 99 1276 67 8762 53 1252 12

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
Community Support

Hi @AMAN560

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

by the way, I want to confirm that,

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.

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

#### Manage your user group events

Check out the News & Announcements to learn more.

#### Microsoft named a Leader in The Forrester Wave

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

#### Power BI Dev Camp - September 30th, 2021

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

#### Microsoft Learn

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

Top Solution Authors
Top Kudoed Authors