Sorting Segments in a Stacked Bar with a Combined Field

This example uses a “combined field” to sort segments within a stacked bar chart. You can only create a “combined field” from dimension fields, so I’ll begin by creating a new date field as a dimension.


1. Create a new calculated field called "Month for Sorting." Make sure the field is a “Dimension.” 

DATEPART('month', [Order Date])

2. Select two dimension fields and right-click to open the context menu. Select Create Combined Field.


3. Add the new combined field to Detail on the Marks card. 


4. In this example, the Fruit field is on Color on the Marks card. Select the field and choose ““ATTR”.

This is a critical step so that the segments will be sorted within an individual bar.


5. Click the drop-down arrow for the “Month for Sorting & Fruit (Combined)” field and choose “Sort.”  Configure the options shown below.

Sort By: Field

Sort Order: Ascending

Field Name: Sales

Aggregation: Sum


6. The finished chart is shown below. The segments in each bar are sorted with the largest sales at the bottom.



Thank you for reading! If you have questions or comments, you can reach me at cryoung6@att.net