How can I sort a stacked column chart in Power BI?

Power BI is a powerful business intelligence tool that allows users to create informative and visually appealing data visualizations, such as stacked column charts. These charts are useful for comparing data values across categories, but it may be necessary to sort them in a specific order for better analysis. To sort a stacked column chart in Power BI, users can utilize the “Sort By Column” option in the Format pane. This allows for the chart to be sorted by a specific category or data value. Additionally, users can also manually drag and drop the columns in the desired order within the chart. These sorting options provide users with a flexible and efficient way to organize their data in a stacked column chart in Power BI.

Sort a Stacked Column Chart in Power BI (With Example)


Often you may want to sort a stacked column chart in Power BI based on the total height of the bars in the chart:

This is easy to do by creating a measure that calculates the sum of each column.

The following example shows how to do so in practice.

Example: How to Sort a Stacked Column Chart in Power BI

Suppose we have the following table in Power BI named my_data that contains information about points scored by various basketball players during three different games:

Suppose we would like to create a stacked column chart that displays the total points scored by each player during each game.

If we would like to be able to sort the bars based on the total height of each bar, we will first need to create a new measure that contains the sum of points scored by each player across all three games.

To do so, click the Table tools tab, then click the New measureicon:

Then type the following formula into the formula bar:

Sum Points = CALCULATE(SUMX('my_data', [Game 1] + [Game 2] + [Game 3]))

A new measure named Sum Points will be created that contains the sum of the points scored by each player across all three games:

Next, switch to the Report View and click the Stacked column chart icon under the Visualizations tab.

Then drag Team under the X-axis, drag Game 1, Game 2 and Game 3 under the Y-axis, and drag Sum Points under Tooltips:

This will produce the following stacked column chart:

The bars are currently sorted in descending order based on the value in the Game 1 column.

To instead sort the bars by the total points scored by each player, click the three horizontal dots in the top right corner of the chart, then click Sort axis, then click Sum Points:

 

The bars in the chart will automatically be sorted based on the total points scored by each player in descending order:

Power BI sort stacked column chart

Additional Resources

The following tutorials explain how to perform other common tasks in Power BI:

x