Sorting Segments Within Stacked Bars by Value
Published: 13 Mar 2014
Last Modified Date: 09 Jan 2019
QuestionHow to sort color segments by value within the stacked bars rather than by value across all the stacked bars.
For example, chart A is a regular stacked bar chart, and chart B is sorted by values within the stacked bar.
|Chart A||Chart B|
Step 1: Create the View
- In Tableau Desktop, connect to Superstore sample data.
- Drag Category to Columns.
- Drag Sales to Rows.
- Drag Region to Color.
- Drag Sales to Label.
Step 2: Sort the Bar Segments
- On Color, right-click Region, and then select Attribute.
- In the Dimensions pane, hold down the CTRL key, click Category, and then click Region.
- With the dimensions highlighted, right-click Region, and then select Create > Combined Field.
- Drag Category & Region (Combined) from Dimensions to Detail.
- On Detail, right-click Category & Region (Combined), and then select Sort.
- In the Sort dialog box, do the following, and then click OK:
- For Sort Order, select Descending.
- For Field, select Sales.
- For Aggregation, select Sum.
To view these steps in action, see the video below:
Additional InformationBy default, stacked bar charts sort along the total for the dimension in the Color shelf.
Discuss this article...