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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
abhiram88
Regular Visitor

How to arrange a stacked bar chart in a custom sequence?

Hello,

I am looking to arrange the legend values of a stacked bar chart in a sequence that is not alphabetical or sorted numerically. I would like to define this order manually. Adding an image of the chart for reference -

abhiram88_0-1749792987152.png

The legend values are all in one column, hence sorting within visul settings is not an option.

 

Thank you in advance.

1 ACCEPTED SOLUTION
Poojara_D12
Super User
Super User

Hi @abhiram88 

In Power BI, when you want to manually control the order of legend items in a stacked bar chart—especially when the legend values come from a single column and are not sorted alphabetically or numerically—you need to define a custom sort order using a supporting column. Since the visual’s formatting options don’t allow manual ordering of legends when they originate from a single column, the best practice is to create a calculated column (in Power BI or Power Query) that assigns a numeric order to each stage (e.g., Planning = 1, Initiating = 2, Executing = 3, etc.). Then, in your data model, you use the “Sort by Column” feature to sort the legend column by this new numeric column. This custom order then dictates how the legend appears both in the visual and in the stacked sequence. For example, if your legend field is called ProjectStage, you can create a new column ProjectStageOrder, and then in Power BI select the ProjectStage column, go to the Modeling tab, and click "Sort by Column" → ProjectStageOrder. This will enforce your custom sequence visually and ensure consistency across charts.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

View solution in original post

1 REPLY 1
Poojara_D12
Super User
Super User

Hi @abhiram88 

In Power BI, when you want to manually control the order of legend items in a stacked bar chart—especially when the legend values come from a single column and are not sorted alphabetically or numerically—you need to define a custom sort order using a supporting column. Since the visual’s formatting options don’t allow manual ordering of legends when they originate from a single column, the best practice is to create a calculated column (in Power BI or Power Query) that assigns a numeric order to each stage (e.g., Planning = 1, Initiating = 2, Executing = 3, etc.). Then, in your data model, you use the “Sort by Column” feature to sort the legend column by this new numeric column. This custom order then dictates how the legend appears both in the visual and in the stacked sequence. For example, if your legend field is called ProjectStage, you can create a new column ProjectStageOrder, and then in Power BI select the ProjectStage column, go to the Modeling tab, and click "Sort by Column" → ProjectStageOrder. This will enforce your custom sequence visually and ensure consistency across charts.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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