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
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
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.

March Power BI Update Carousel

Power BI Community Update - March 2026

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