Tableau Tips: Sorting Stacked Bars

Hello Folks,
In this blog I will show you how to sort stacked bar charts. Sorting of stacked bars charts enable us to see the composition of the trend of the dimension that we want to have a look at. We will use our sample super store data for this. Before we go to sorting of the stacked bars, lets first try to build it.
To do that follows these steps:
1- Drag order date to the columns. Right click on the Date pill in the columns and select Month from the dropdown.
2- Drag sales to the rows and change the mark type to bars.
Your screen at this point will look like this:

3- Now lets drag region to the colors mark.
4- Right click on the sales pill in the rows and add a quick table calculation percentage of totals. Compute it along Region.
5- Click on the Ctrl button and drag the measure sum in the rows to Labels.

Your should now have this on your screen:

Now we see in the above charts that the bars are not sorted . What we want to achieve is that for the month of Jan we have Central at the top then South, then West and finally east as the sales in east is the lowest in the month of Jan. Similarly it should be for all the months. To do that follow the steps as under:

6- Create a calculated field as under :
7- Create a combined field using region and Month that we created in the above step. To create a combined field Ctrl click on Region and Month >> Right click and then from the dropdown select create combined field.

8- Drag the combined field Region &Month to detail.
9- Drag the field region to detail.
10- Right click on the Region & Month Field on the details mark and then click on sort. Select descending and sort by Sales (sum)
There you go , you can now see that the regions are now sorted for every month. Hope you guys find it useful.
Let me know in case if you are not able to follow any steps.


Please follow and like us:

1 Comment

  1. Hi Rahul,

    This is great! Could you also let me know me how to sort the measure in stacked bar chart. I am using two measures demand and capacity. I want to sort the stacked bar based on the min value should come first and then the max value.


Comments are closed.