6 Replies Latest reply on Jun 5, 2013 11:54 AM by Jonathan Drummey

# Marking Stacked Bar Charts with Percent of each Bar, Sum to 100%

Hello,

I have a stacked bar chart, each complete bar labeled with the % it makes of a total population. See Figure 1, below. I am using Tableau 6.1.

Now, each of these individal bars I would like mark what percent each different colored part of the bar makes up of the whole bar. For example, I currently have a bar that makes up 12% of the population, this is composed of subgroups that make up 3%, 3%, 6% = 12%. However, what I want is those Mark Labels to say 25%, 25%, 50%.

The first attached image is what I currently have. The second image describes how I want the bars labeled but I would prefer them to be in a stacked bar, not seperate rows.

Thank you for taking the time to look into this. I did what I could to scour other discussions for related advice, any recommendations appreciated!

• ###### 1. Re: Marking Stacked Bar Charts with Percent of each Bar, Sum to 100%

Hi,

I believe what you're looking for is something like the following, which makes use of two separate % of Total table calculations, with different Compute Using settings.

Both % of Total Calc's use the same formula as the Percent of Total Quick Table Calculation. The one on Rows is set to Compute Using Table Across, the one on the Label Shelf is set to Compute Using Category, so it restarts (partitions) the calculation for each Container. See the attached for an example.

Cheers,

Jonathan

• ###### 2. Re: Marking Stacked Bar Charts with Percent of each Bar, Sum to 100%

That's perfect, thank you!

• ###### 3. Re: Marking Stacked Bar Charts with Percent of each Bar, Sum to 100%

Hi Jonathan,

I realize you posted a long time back, with your solution " percent of total within container.twbx.zip"

Right now I'm facing a similar problem, but with a greater complexity within the data. I have subcategories within each of the product types and I wish to show the % Totals for each of the categories.

e.g In this case, you have Cafe Latte as a % of Total coffee sales. What I have is say, Cafe Latte I, II and III, and within the Cafe Latte bar I wish to show % of Cafe Latte I out of Total Cafe Latte sales.

So as an overall output, I want a "Show Button" with two options- one to show the actual sales for each sub-brand. And the other is to show it as % of sub-brand within the brand.

Will be glad if you could help!

To maintain client confidentiality, I can't share the workfile here.

• ###### 4. Re: Marking Stacked Bar Charts with Percent of each Bar, Sum to 100%

Hi,

Table calculation compute using settings are very particular, so without a better sense of your hierarchy and what you want each % of total to be of it's hard to give you something useful. Please use the product hierarchy in the superstore sales sample data to create a mockup of what you want, then I or someone else on the forums can help you get what you need.

Jonathan

• ###### 5. Re: Marking Stacked Bar Charts with Percent of each Bar, Sum to 100%

Hi Jonathan, sorry for the confusion. I've attached a sample data set here. I've created two worksheets and I wish to toggle between the two views created therein, perhaps using parameters.

Thanks,

Shalin.