Custom Axes in Tableau

Mar 4, 2022

Klaus Schulte

In this blog I’d like to share one of the coolest things I’ve ever created in Tableau.

But what is so cool about this viz? You’ve probably already seen thousands of such curvy line charts. (If you want to learn how to create them, read Kevin Flerlage’s blog on it or even take his template from Tableau Public.)

The thing I want to talk about in this blog is a rather subtile element of this viz: it’s the custom axes in my parallel coordinates plot.

Custom What?

Let’s take a closer look:

There are in fact lots of axes in this visualization, but the axes we see actually aren’t. They are part of the visualization itself, and they are the topic this blog is about.

How to Create Them

We’ll need a wild mix of Tableau functions to create them, including exotic functions like LOG, POWER, CEILING and FLOOR, but hey, let’s do it!

The Data Model

An axis needs a ruler and some tick marks. Therefore in my axis model you see 1 ruler object and 12 tick mark objects (more on that later). For each object I need 2 points to draw a line (->2 points in Model). Relationship on 1=1 to put everything together.

Ranges

The scalings of the axes depend on the range to be displayed. To keep it dynamic, we need a couple of calculations to find the maximum and the minimum value (could also be a constant like 0) on each axis, and to calculate the range between both. And now the fun begins…

Log

First thing we need to do is to calculate the logarithm to base 10 of my ranges using the function LOG. This gives us back the value by which we have to exponentiate 10 to get the ranges back.

Ceiling

Next step is to use CEILING to round up the value from the previous step. This way we determine the number of digits of the respective range, e.g. 5 digits for the DREB range of 11,367.

Then I calculate the difference between the log value and the ceiling value of the log value, to determine the actual scale in the next step.

Scale

The scale is calculated with POWER & the ceiling value. For diff>-0.30103 it will be 10 to the power of the ceiling value -1 (0.01, 0.1, 1, 10, 100,…)., for the next range (-0.60206 till -0.30103) I divide by 2 (0.05, 0.5, 5, …) and else by 4 (0.025, 0.25, 2.5, 25).

Now we can use this Axis scale value to determine the minimum and maximum tick mark, using our Min and Max KPI value and again the CEILING and the FLOOR function…

…which will give us eventually the number of ticks needed on our axis.

Labels

For the tick labels, we start with Tick_min and add further steps as long as the (Object ID-1) is less or equal than the number of steps needed.

Position

Last step: calculate the position of each value based on Tick_max and Tick_min. This does not necessarily have to be an aggregation like I did here.

Putting the Viz Together

Last step is to put everything together – and that’s it!

Check out the workbook on Tableau Public to learn how to put the curvy lines and and the axes view together.

Is all of this relevant for business users? For 99.9% of them probably not. I can imagine very few use cases, for example when you want to reverse an axis on user control. Or when you just want to bring in axes where Tableau by default doesn’t.

Thanks for reading – if you have feedback, you can find me on twitter!