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
Antmkjr
Helper V
Helper V

Sort Values in a stacked column chart

https://drive.google.com/file/d/1GxPiajMP6seQSnRFa7eLVlJdm9Hvri8w/view?usp=sharing

 

How to sort the values in a stacked  column chart basd on value. Link to pbix attached.

 

AnuTomy_0-1655454328306.png

 

9 REPLIES 9
v-shex-msft
Community Support
Community Support

Hi @Antmkjr,

You can also take a look at the following blog to create a custom sort table to apply specific sorting order based on the 'sort by column' property and table relationship:

Custom Sorting in Power BI  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
NickolajJessen
Solution Sage
Solution Sage

Add some sort of index column and use the "Sort by" 

NickolajJessen_0-1655454937455.png

NickolajJessen_1-1655454952246.png

 

AnuTomy_0-1655455558805.png

I want to sort by Sal value

Use index to rank based on sal

NickolajJessen_0-1655456028429.png

Note that this is done on a dimesions table.


Note this cal also be done without the support column: 

RANKX(countries,
    CALCULATE(
    SUM('Table'[Sal])
))



If this post solves your problem, accept it as a solution
Appreciate your kudos

https://drive.google.com/file/d/1GxPiajMP6seQSnRFa7eLVlJdm9Hvri8w/view?usp=sharing

Suppose if i am ranking as below, i am not able to sort the country column.(In real case i have to rank countries,after filtering certain records ,like mentioned below)

 

Indexj = RANKX('Table',SUMX(CALCULATETABLE(FILTER('Table','Table'[Country]<>"Pakistan"), ALLEXCEPT('Table',Country)),'Table'[Sal]))

 

AnuTomy_0-1655466036103.png

Getting the below errror, and hence not able to sort the legends

AnuTomy_0-1655578738007.png

 

Is there anything wrong with the solution i provided?

In the case mentioned above , it is not working?

Well, you are not trying the solution i provided, haha.


@NickolajJessenwrote:

Note that this is done on a dimesions table


Also, if you don't want a country to appear, you can just filter it away in your visual. I don't think you need to filter it in your ranking.

This scenario i just gave  as an example, in actual case, there many more filters than this.

 

Indexj = RANKX('Table',SUMX(CALCULATETABLE(FILTER('Table','Table'[Country]<>"Pakistan"), ALLEXCEPT('Table',Country)),'Table'[Sal]))

In this case it is giving circular dependency error.

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.