Question

Display % of totals on a stacked bar graph


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?


14 replies

Userlevel 3

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.

Userlevel 3

This is a little feature we would also appreciate 🙂

@paola Hi, did it resolved yet, do we have a way to show % instead of actual count in stacked bar graph?

Userlevel 2

@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.

Same. This would be very useful.

We will also appreciate this feature.

Userlevel 3

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!

Userlevel 3

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.

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.


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.

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

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)

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.

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?

Reply