Add a label above every horizontal bar in Tableau

Hi, today I would like to share a trick I learned, which is to add a label above every horizontal bar in Tableau.

Let's use the superstore data to create a basic bar chart, with sum of profit on columns shelf and region in the rows shelf.

The next is to create a dummy row above each bar. This can be done by adding a dummy in-field calculation. The steps are as follows:

  1. double-click the columns shelf and type 'avg(0)'
  2. right-click the avg(0) and select 'Dual axis'
  3. right-click the x-axis in the bar chart and select 'Synchonzie Axis'
  4. Click the marks card of AGG(avg(0)) and drag the Measure Names pill to the rows shelf.  
  5. The new dummy rows may appear below the bars. Just drag the bar label near the bars down below the dummy rows. This will solve the problem.
  6. Set the size and opacity of color of our dummy mark card as 0%.
Add a label above every horizontal bar - part1

Now we need to add the labels and finish the chart.

  1. Drag the desired fields on the Text for the dummy mark card to show the label. Format the label a bit so that it appears in a single line.
  2. Remove the redundant headers for both x- and y-axis.
  3. Remove the redundant grid lines and dividers.
  4. Change of dummy mark card from 'Bar' to 'Gantt Bar' to remove the tiny dot next to the label.
Add a label above every horizontal bar - part2

This is how you add a label above every horizontal bar in Tableau

Feel free to check out my other posts and connect with me on Linkedin - learn and improve together!
https://www.thedataschool.co.uk/blog/stanley-chan

Author:
Stanley Chan
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab