Show percent_of_total and count in the same chart bar

  • 7 September 2015
  • 2 replies

Hello, i have a chart that displays a count of users grouped by range of ages. The chart is displaying correctly, showing in the chart, one bar for each different age interval and displaying the count measure. Is it possible to show the percent_of_total when the users hovers each bar? Right now is only displaying the count value, but i’d like to add the % of total also without adding a new column.

For example, if total is 100, i’m showing 3 bars with the next values

“Age < 10” : 25 users

“Age 10-20”: 40 users

“Age > 30”: 35 users

i’d want to show something like this

“Age < 10” : 25 users (25% of total)

“Age 10-20”: 40 users (40% of total)

“Age > 30”: 35 users (35% of total)

Is it possible to do something like this?


2 replies

Userlevel 3

Hey Julio,

My colleague, Zach, just wrote a post that I believe could help you out, in it he uses liquid html to bring through the percent of total value into the viz as a hover over.

Check it out here.

Sorry for the delay Nicole, it worked great!

It was as easy as creating a percent_of_total measure like this:

  - measure: count_percent
type: percent_of_total
sql: ${count}

and then adding this html field to my default count measure

    html: |
{{ rendered_value }} ({{ count_percent._rendered_value }})

This displayed “count (count_percent)” when hovering the bar, but only displaying the count in the value.