cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ljuturi1
Helper I
Helper I

Custom Sorting

Hi Thank in advance to solve this issue. this is the scenario I have table having values like customer and respective values here I need custom sort function. below is the table for reference.

 

ljuturi1_0-1669977165249.png

Here I need Samsung is the bottom of the stacked bar ireespective of any value remaining customers arrange their based on the value sort by higher to lower. is there any way to get through DAX, I tried multliple ways here but not getting the expected results. Can some one please help here That really appreciated.

 

Thank you so much in advance.

 

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

Hi  @ljuturi1 ,

I created some data:

vyangliumsft_0-1670213614627.png

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
var _table=
SUMMARIZE('Table','Table'[Customer],"Sum",SUMX(FILTER(ALL('Table'),'Table'[Customer]=EARLIER('Table'[Customer])),[Value]))
return
ADDCOLUMNS(
    _table,"rank",RANKX(ALL('Table'),[Sum_Measure],,ASC,Dense))

vyangliumsft_1-1670213614628.png

2. Relationship to join two tables.

vyangliumsft_2-1670213614629.png

3. Select [Customer] – Column tools – Sort by column – [rank] for the new table.

vyangliumsft_3-1670213614633.png

4. Result:

vyangliumsft_4-1670213614637.png

 

Best Regards,

Liu Yang

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

Hi  @ljuturi1 ,

I created some data:

vyangliumsft_0-1670213614627.png

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
var _table=
SUMMARIZE('Table','Table'[Customer],"Sum",SUMX(FILTER(ALL('Table'),'Table'[Customer]=EARLIER('Table'[Customer])),[Value]))
return
ADDCOLUMNS(
    _table,"rank",RANKX(ALL('Table'),[Sum_Measure],,ASC,Dense))

vyangliumsft_1-1670213614628.png

2. Relationship to join two tables.

vyangliumsft_2-1670213614629.png

3. Select [Customer] – Column tools – Sort by column – [rank] for the new table.

vyangliumsft_3-1670213614633.png

4. Result:

vyangliumsft_4-1670213614637.png

 

Best Regards,

Liu Yang

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

@ljuturi1 , You need to create sort column

 

Example

customer1 =[customer]

 

 

customer Sort = Switch( [customer],

"Samsung",1,

"Hp",2,

//Add other

 

10)

 

Mark customer sort as sort column of customer1 and use customer1 in visual

 

PowerBI Abstract Thesis Episode 6: How to Create Sort Column and Solve Related Errors:
https://www.youtube.com/watch?v=KK1zu4MBb-c

Thanks for your response limited customers then it will lwork but I have N number of customers thats why I am requesting is there any option to change dynamically.

Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors