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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
jj304
Frequent Visitor

Sort 100% stacked bar chart by percentage descending order

Hi, I have a  power bi report using direct query that has a 100% stacked bar chart that displays the volume by users split by category.

 

The columns are

  • Y-axis - User 
  • X-axis - Sum of volume
  • Legend - Category

 I would like to sort the bars to display by percentage in descending order but currently it always sorts by the legend.  Any ideas how I can force it to sort by % volume.  Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jj304 ,

 

Since we can't use measure for y-axis, to achieve this sorting effect, I suggest you create a calculated table:

NewTable = ADDCOLUMNS(
    'Table',
    "AdjustedUser1", IF(
        'Table'[Category] = "A",
        RANKX(
            FILTER('Table', 'Table'[Category] = "A"),
            'Table'[Volume],
            ,
            ASC,
            DENSE
        ) & "_" & 'Table'[User]
    ),
    "NewUser1", CALCULATE(
        MAX('Table'[AdjustedUser1]),
        ALLEXCEPT('Table', 'Table'[User])
    )
)

Then use the columns in the new table to create a bar chart.

 

Best Regards,
Zhu

 

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

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Thanks for the replies from parry2k.

 

Hi @jj304 ,

 

According to your description, I created simple data.

vlinhuizhmsft_0-1738748954333.png

 

When sorting this chart, it can only be sorted by one of the X-axis or Y-axis, if at the same time, you need the percentage to show the effect of descending, you can create a new calculated column that meets the descending order of the percentage, and use it as the Y-axis. The steps are as follows:

1. Create calculated columns:

 

AdjustedUser = IF('Table'[Category]="A",RANKX(FILTER('Table','Table'[Category]="A"),'Table'[Volume],,ASC,Dense)&"_"&'Table'[User])
NewUser = 
CALCULATE(MAX('Table'[AdjustedUser]),ALLEXCEPT('Table','Table'[User]))

 

vlinhuizhmsft_3-1738749539411.png

 

2. Use Newuser as the y-axis and sort by it:

vlinhuizhmsft_2-1738749442011.png

 

3. Comparison of results:

vlinhuizhmsft_4-1738749584483.png

Best Regards,
Zhu

 

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

Hi @Anonymous, thanks for your reply.  I am using Direct Query for this report so i cannot use this dax in a calculated columns.  When i try to use the dax in a measure it forces me to use some form of aggregration for the columns. 

Anonymous
Not applicable

Hi @jj304 ,

 

Since we can't use measure for y-axis, to achieve this sorting effect, I suggest you create a calculated table:

NewTable = ADDCOLUMNS(
    'Table',
    "AdjustedUser1", IF(
        'Table'[Category] = "A",
        RANKX(
            FILTER('Table', 'Table'[Category] = "A"),
            'Table'[Volume],
            ,
            ASC,
            DENSE
        ) & "_" & 'Table'[User]
    ),
    "NewUser1", CALCULATE(
        MAX('Table'[AdjustedUser1]),
        ALLEXCEPT('Table', 'Table'[User])
    )
)

Then use the columns in the new table to create a bar chart.

 

Best Regards,
Zhu

 

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

parry2k
Super User
Super User

@jj304 check the sort column by clicking the 3 dots on the visual.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@jj304 on the format pane, under layout, turn reverse order on and that will do it.

 

parry2k_0-1738681037320.png

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

jj304
Frequent Visitor

Hi @parry2k, thanks for your reply.  The reverse order reverses the ordering of bars but its still displaying by the legend (category) 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.