MIP Logo

Formatting Trick with Reference Line in Tableau

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here

The Problems:

In Tableau, Bar Chart is the most popular and used widely. Overtime, the creative users of Tableau have come up with different types of Bar Charts to make their Dash Board engaging. You decided to try out some fancy version of bar chart, and you picked a custom chart. Everything’s looking good so far, until you turn on your labels. You would ended up with something like this.

The labels on Standard Barchart looks just fine, but you will notice that your labels on Dual-Axis Bar Chart were overlapped with the bar itself. To ensure that you won’t run into this problem, with any kind of bar chart, here is a little trick with Reference Line in Tableau to sort this issue out.

How To:

Two elements we need for this trick to work: Reference Line and a Calculated Field.

Where Is The Reference Line ?

First, you need to locate the Reference Line in Tableau. You can find it in Analytics Tab, right next to Data Tab. Under Custom,

Drag Reference Line into the Sheet. You will see Add a Reference Line tab appears (see image below). Choose Table, ignore other options for now !

and Calculated Field ?

Make it Work !

We need a custom values for the Reference Line to work for our trick. And for that we use a Calculated Field to create this custom values. In this case, we are working with Sum of Sales, so lets use Sales. Here the tricks, we need the Reference Line to slightly above the highest value in the sheet. Lets create a Calculated Field, name it something appropriate, like ‘Ref Line’ will do.

In side Calculated Field, use this formula: WINDOW_MAX(SUM([Sales])) * 1.2. You can change the Measure or numeric values  as desired. Then drag ‘Ref Line’ into Detail on Mark (see below).

What it does ? WINDOW_MAX calculation always looks at highest value in the view, in this case is Chairs, and multiplied with 1.2. This made the axis “stretch out” a little bit just enough to display the label properly. Yes, we can manually adjust the tick axis, but that won’t be dynamic.

Add Reference Line into View with following setting, then click OK:

             

Now you should be able to see your bar charts with label displayed properly

Share this post