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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Dharma0208
New Member

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.