# Display % of totals on a stacked bar graph

(Sean Corson) #1

I have seen very useful tips on how to show the % of totals in the tooltips when you hover over a stacked bar chart, is there a way to display that % of total on the bar itself rather than in the tooltip?

(jonathon) #2

Hey @smcorson, Thanks for the question. You can display the % of total on the bars by clicking on the viz options, â€śValuesâ€ť tab, and then enabling the `Value Labels` toggle.

Here is a screenshot of a Learn Explore I mocked up showing where this feature can be enabled.

(Sean Corson) #3

Sorry, I wasnâ€™t very clear. If I have a stacked bar graph with numbers (not % of total), can I create a value label that shows the % of total rather than the total numbers? In other words, if you changed the bar chart in your example to a stacked chart then the value labels would display round numbers, not % of total. I would like to create a stacked chart with round numbers that showed a value that was the % of total.

(Aleksandrs Vedernikovs) #4

@smcorson

Hey Sean,

I was playing around with your question for some time and could not figure out how can we achieve this with Stacked bar graph. However, I managed to create what you wanted with Grouped. I made you the learn account and sharing the link here, so you can test it yourself:

https://learn.looker.com/explore/the_look/order_items?qid=7nZMTq90bqCTbe4kxboEVq&toggle=dat,vis

So percent_of_total is showing up on top of the column and if you hover over the column you can see the actual count number also. You do need to create the percent_of_total column using table calculations. Hope this helps.

(Patrick Bibb) #5

But if I am interested in seeing the change over time and how total volume affects percentage, then stacked is a better visual. For example if I have a tiered or bucketed dimension like time (i.e. 2-3 hours, 4-6 hours etc). Found a post where you can do this in excelâ€¦ https://www.extendoffice.com/documents/excel/2370-excel-show-percentages-in-stacked-column.html

(Paola) #6

Hey @Patrick_Bibb ! I took a look at your example and this isnâ€™t currently possible. I can definitely pass your use case & feedback along to our product team.

We could however, visualize just the percent of total over time as shown below. Note that the y-axis shows the percentage and not the total, as in your example.

(Alex Hancock) #7

This is a little feature we would also appreciate

(Arpit Jain) #8

We will also appreciate this feature.

(Shane Leese) #9

I also think this would be useful, to display the percent of total in the stacked bar tooltip (but keep the y-axis as the actual values)

#10

Same. This would be very useful.

(Catherine Huang) #11

Hi Paola, would you be able to share how you were able to create this? iâ€™ve been working on something exactly like what you made but couldnâ€™t figure it out.

(Paola) #12

Hey @Catherine_Huang, sure thing!

We can create the percent of total field using Table Calculations. In my example above, I used the function `\${users.count}/sum(\${users.count})`

Once you have that, you can hide the the Users Count column from the visualization. Change the visualization plot settings to â€śStackedâ€ť and toggle on â€śValue Labelsâ€ť.

Hope this helps!

(Catherine Huang) #13

Thank you so much! awesome! is there a way to also show the actual count in the tooltip black box w i hover my mouse over to the bar graph area?

(Paola) #15

No problem If youâ€™d like to change whatâ€™s displayed in the tooltip, I recommend going through this discourse article which will walk you through how to use Liquid to change those values.