13 Replies Latest reply on Mar 17, 2017 10:08 AM by John Sobczak

# 100% stacked bar chart and absolute Total on Top of bars

Hi All,

I hope you are doing fine.

I have create a 100% stacked bar chart, that displays absolute values within bars.

Now I need to have the Total at top, but bars should stay as it is.

Workbook is example. If I add a reference line in my original chart, bars won't show because total would be too high.

Is there a different way to get totals?

For any hints I am really thankful.

Best regards

Sabine

• ###### 1. Re: 100% stacked bar chart and absolute Total on Top of bars

See this one.

• ###### 2. Re: 100% stacked bar chart and absolute Total on Top of bars

Hi Sabine, is this what you're looking for? I used a false measure to make a dual axis. The value displayed on the dual axis is the total, and the axis is positioned such that it appears above the bars. You can hide the right axis to complete the effect.

1 of 1 people found this helpful
• ###### 3. Re: 100% stacked bar chart and absolute Total on Top of bars

Hi David,

thank you very much for the quick reply.

That was I was looking for :-)

Thank you

Best regards

Sabine

• ###### 4. Re: 100% stacked bar chart and absolute Total on Top of bars

Hi Luciano,

thank you very much for the quick response :-)

It really helped me.

Best regards

Sabine

• ###### 5. Re: 100% stacked bar chart and absolute Total on Top of bars

Hi David

I have difficulty when I try to replicate your work.

Please see the picture -- I don't understand the logic behind your process.

• ###### 6. Re: 100% stacked bar chart and absolute Total on Top of bars

Look carefully at each tab in the Marks card. The one with MIN(0.98) shouldn't have dimensions in it (or at least not Cat). Also, the right axis needs to be fixed to 0-1.

• ###### 7. Re: 100% stacked bar chart and absolute Total on Top of bars

Let me share with you how I did it.

1) Create a calculated field "Second axis" with a value of 1.01

2) Drag this calculated field to the end of the x axis, so as to make a dual axis chart.

3) Change the aggregation of "Second axis" (on the rows) from SUM to MIN.

3) Change the range of the secondary axis from 0-1

Should give you this:

• ###### 8. Re: 100% stacked bar chart and absolute Total on Top of bars

Hello!

Here I am, resurrecting this question.

I'm replicating the exercise but I don't get how does the 'second axis' calculated field gives us the total sum of sales we want to put at the top. What is happening when we create the dual axis that allows it?

Thanks in advance,

Esther

• ###### 9. Re: 100% stacked bar chart and absolute Total on Top of bars

The 2nd axis creates another marks card layer that allows you to put a completely different set of measures and dimensions as labels, colors, size, etc.

• ###### 10. Re: 100% stacked bar chart and absolute Total on Top of bars

Hey John,

I get that, what I don't get is how does the 2nd axis know it's the total sales we want to see, because we are not defining it anywhere.

• ###### 11. Re: 100% stacked bar chart and absolute Total on Top of bars

Esther,  Oh but you are defining it.  It is the measure you have on the text mark for that marks card layer:    Sum(Value) for the segmented colors and the total is being done through a reference line.

1 of 1 people found this helpful
• ###### 12. Re: 100% stacked bar chart and absolute Total on Top of bars

Oh, I get it now! What a sneaky trick it is

Thanks John Sobczak!

• ###### 13. Re: 100% stacked bar chart and absolute Total on Top of bars

Esther,  Sure.  As you use it more and more you will discover it seems there is almost no end to tricks that can be done in Tableau