4 Replies Latest reply on Aug 6, 2018 3:02 PM by Keith Salach

# Calculate the Total of a Stacked Bar Chart

Greetings!  I have a beginner's question about calculations.

I am trying to calculate the total value for a stacked bar chart and add that to the tooltip.

The stacked bar shows monthly activity across the X axis and the bars have two attributes grouped by color.  The bars are counting records by month.

I am struggling to get a result that makes sense.  I tried a FIXED LOD calc that works for most months.  However, for one month my calculation is not working.  I am actually getting an incorrect result for both of the color groupings.  I believe the reason is because there is not a value for each day in my data set.

Example:  if the GRAY group has 40 and the BLUE group has 50, I would expect my total calc to show 90.  But instead, it is showing something like 88 in GRAY and 87 in BLUE.

Is there a different calculation I should be using?  Let me know if more info is needed to answer the question.

Thanks!

Keith

• ###### 1. Re: Calculate the Total of a Stacked Bar Chart

Hi Keith,

Have you tried using TOTAL()  ?

HTH

Peter

• ###### 2. Re: Calculate the Total of a Stacked Bar Chart

Hi Keith,

1) Create a reference line

2) Select Per pane

3)In value ->Total

4) Label should be Value

5)Line should be none

4) Label should be Value

Or please go thru this link: Tableau Workaround Part 3: Add Total Labels to Stacked Bar Chart - Credera

1 of 1 people found this helpful
• ###### 3. Re: Calculate the Total of a Stacked Bar Chart

There's an easier way to do this - just create a dual-axis, one with the dimension on Color and one with no dimension on Color.  Sync the axis and arrange the labels and then it will work easily.

I think this request was more about putting the total in a tooltip, so using TOTAL() (as mentioned earlier) will work better, faster and more logical to follow as well.

1 of 1 people found this helpful
• ###### 4. Re: Calculate the Total of a Stacked Bar Chart

Thank you Peter!  Yes, this worked.  I had to figure out the "compute using" setting and got what I needed.