Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

See when key Fabric features will launch and what’s already live, all in one place and always up to date. Explore the new Fabric roadmap

Reply
Anonymous
Not applicable

sort 100% stacket column chart by created measure

Hello everyone, I have the followin stacket column chart, and I woukd like to sort the the percent values and is not working by the ordinary way. I only have the option below., and if the I choose market share asc or desc nothing happens, there's a way to put the the the larger number at the end and grow the stacked till the lowest? In the image is working cause a I put some space/tab into the name of legend.

 

GuiGentil_1-1645468606642.png

 

GuiGentil_0-1645468559918.png

 

The measure is 

Market Share =

VAR RAT =
sum(SOA[Rat_Per])

var allRAT =
CALCULATE( sum(SOA[Rat_Per]), ALL ( SOA[Owner]))

RETURN
DIVIDE(RAT,allRAT)

 

1 ACCEPTED SOLUTION
KNP
Super User
Super User

I don't know an easier way other than what you've tried to do with the legend.

You can however, do the same thing without it visibly affecting the legend.

 

I do something similar to control complex table sorting requirements with this...

SortUnderHours = 
//UNICHAR(8203) is a zero width space REPT() repeats a character x many times.
//More spaces sort at the top when in DESC order.

VAR __HR = [HoursRemaining]
VAR __DCE = [DaysToCycleEnd]
VAR __HRCD = [HoursRemaining_CycleDays]
VAR _c = 8203
RETURN
SWITCH
    (TRUE()
        , __HR <= 0, BLANK()
        , AND(__DCE = 0, __HR > 0), REPT( UNICHAR(_c) , 3)
        , __HRCD > 12, REPT( UNICHAR(_c) , 5)
        , __HRCD >= 8, REPT( UNICHAR(_c) , 4)
        , __HRCD < 8, REPT( UNICHAR(_c) , 2)
        , BLANK()

    )

 

You could adapt this for your legend potentially to control the sorting. It'll take some work which I don't have time for right now but hopefully it'll get you started.

 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, Can u please explain in detail  how it got resolved.

Anonymous
Not applicable

Hi @Anonymous ,

It is not supported to sort a stacked column chart by value in Power BI currently .There is an idea about this issue, please vote it up,  Stacked bar chart total sort , to improve the Power BI.

 

I have also found a similar post, please refer to it to see if it helps you.

Stacked column chart: Sort legend by value, not alphabet 

  • If you have only one category on X-axis, you can have your Legend column sort by Value column.
  • If you have multiple catgories on X-axis, this method will not work. You have to manually define the order column in your table. 

Best Regards

Community Support Team _ Polly

 

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

KNP
Super User
Super User

I don't know an easier way other than what you've tried to do with the legend.

You can however, do the same thing without it visibly affecting the legend.

 

I do something similar to control complex table sorting requirements with this...

SortUnderHours = 
//UNICHAR(8203) is a zero width space REPT() repeats a character x many times.
//More spaces sort at the top when in DESC order.

VAR __HR = [HoursRemaining]
VAR __DCE = [DaysToCycleEnd]
VAR __HRCD = [HoursRemaining_CycleDays]
VAR _c = 8203
RETURN
SWITCH
    (TRUE()
        , __HR <= 0, BLANK()
        , AND(__DCE = 0, __HR > 0), REPT( UNICHAR(_c) , 3)
        , __HRCD > 12, REPT( UNICHAR(_c) , 5)
        , __HRCD >= 8, REPT( UNICHAR(_c) , 4)
        , __HRCD < 8, REPT( UNICHAR(_c) , 2)
        , BLANK()

    )

 

You could adapt this for your legend potentially to control the sorting. It'll take some work which I don't have time for right now but hopefully it'll get you started.

 

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

Check out the May 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.