Sorting Stacked Bars by the Percentage of One Segment
Published: 28 Jan 2021 Last Modified Date: 01 Feb 2021
Question
How to sort the stacked bar graph by the percentage of one segment just like below.
Environment
Tableau Desktop
Answer
Create a calculation to get the percentage of the segment and sort the view by it.
1. Make a calculation like below to the percentage for 'Home Office'. IF ATTR([Segment]) = "Home Office" THEN SUM([Sales]) / TOTAL(SUM([Sales])) ELSE 0 END
2. Add this field to [Columns] Shelf along with the original measure
3. Edit table calculation Compute Using > Cell to show the right percentage
4. Sort the view by the percentage calculation.
Thank you for providing your feedback on the effectiveness of the article.