Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
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 -
The legend values are all in one column, hence sorting within visul settings is not an option.
Thank you in advance.
Solved! Go to Solution.
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.
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.