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
hongyuliu
Helper III
Helper III

Sorting

Hi,

 

Can someone please advise how to sort the name by the way I want?

 

I'm working on PnL report, I want to show asset first in a matrix, then liability, equity, income and expense.

But when I put them in Matrix, it always shows asset, equity, expense, income and liability.

 

Please adivse, thank you very much.

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

Hi @hongyuliu ,

 

If your data is similar with the sample I built below:

Name-Sort.PNG

Based on my test, using SWITCH() to add a Sort column and then sorting Name column based on it will lead error:
sort error.PNG

 

In this case , please follow these steps:

1. Create a new table for sort:

ForSort = ADDCOLUMNS( VALUES(Table2[Name]) , "Index", SWITCH([Name],"asset",1,"liability", 2,"equity",3,"income",4,"expense",5))

2.Select Name column, then sort Name column by Index column:

sort name by index.jpg

3. Build relationships between two tables:

build relationship.PNG

Now you could create a Matrix visual as you expected:

sort as expected.PNG

Best Regards,
Eyelyn Qin
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
pramodreddy
New Member

How to sort in ascending 

0-50k

50k-100k

100k-150k

150k-200k

 

v-eqin-msft
Community Support
Community Support

Hi @hongyuliu ,

 

If your data is similar with the sample I built below:

Name-Sort.PNG

Based on my test, using SWITCH() to add a Sort column and then sorting Name column based on it will lead error:
sort error.PNG

 

In this case , please follow these steps:

1. Create a new table for sort:

ForSort = ADDCOLUMNS( VALUES(Table2[Name]) , "Index", SWITCH([Name],"asset",1,"liability", 2,"equity",3,"income",4,"expense",5))

2.Select Name column, then sort Name column by Index column:

sort name by index.jpg

3. Build relationships between two tables:

build relationship.PNG

Now you could create a Matrix visual as you expected:

sort as expected.PNG

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

amitchandak
Super User
Super User

@hongyuliu , You have to create a sort column and mark that a sort column for you column and use that

 

Name 1 = [Name]

 

Name Sort = Switch( [Name],

"liability", 1,

"equity",2,

"income",3,

// Add others

100 //default )

 

Mark Name sort as sort column of name 1 and use name 1 in visual

 

refer if needed

How to Create Sort Column and Solve Related Errors: https://youtu.be/KK1zu4MBb-c

 

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

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.