Here in this bar chart, i have plotted total admissions against age groups. The admissions is a calculated field derived from female count + male count. Now I want a stacked bar chart with distinct colors for female and male count/percentage. How can I do that?
#Tableau Public
you'll want to Pivot your data in the data source tab (1st tab of every workbook).
Go to the data source tab, select Male/Female columns, then right-click and from the menu of options, select Pivot:
From there, you'll then see Tableau represents the data as Pivot Field Names and Pivot Field Values (you can click into the header and rename these):
Then you can build your view:
To get the percentage of same, drag another SUM( [Gender Counts] ) as example field. Then right-click and select Quick Table Calculation, then from sub-menu to that, select Percent of Total.
Then set the compute by to use Table Across:
You'll then have what you've asked for in your post:
If this response answered your question, please mark it as an Accepted Answer?
This way, others searching for similar solutions will find the answer faster in the future.
Best, Don Wise (Tableau Ambassador)