09 Jun 2016

How to Build a Sankey Chart in Tableau + a Euro 2016 Viz You Can't Miss

Ryan Smith

Sankey Charts are something that you may not be familiar with; I have vague memories of using them in science at school to visualise the efficiency of a light bulb. Though Tableau doesn't necessarily have a 'Sankey' option when it comes out of the box, there are some workarounds to make Tableau do "what you want it to do" not just "what it can do". Though Sankey functions are limited, they can produce some stunning vizes. Here's a step-by-step guide to creating a Sankey Chart in Tableau.

Step 1 – Data Prep

Before you begin to use Tableau, you must first have your data correctly prepared. Each record needs to have a "Position 1" field for its starting point (in this case Nationality) and then a "Positon 2" field for its destination (in this case Current League).

Sankey Chart Tableau

To produce the Sankey's signature flowing lines we need to use an exponential function. The way to utilise this is by using a model to shape your lines. The model has an incremental value that when joined to the primary data produces points that will be manipulated using an exponential function that I'll explain later within this tutorial.

Model Sankey

Step 2 – Tableau Calculations

Now that our data is prepped and ready to go we can begin to build our Sankey within Tableau. Two main calculations are crucial to producing a Sankey: the "Sigmoid Function" calculation and the "Curve" calculation. The "Sigmoid Function" is the exponential function I mentioned earlier and it produces the distinctive curves of the Sankey.

Sankey Chart Tableau

The "Curve" calculation uses the sigmoid function to plot the lines and form our Sankey. Here I use the "Position 1" and "Position 2" fields to produce my lines from start to finish.

Sankey Chart Tableau

Step 3 – Build

Now that all the hard work is done, we can take advantage of Tableau's great usability to just drag and drop our calculations onto the correct place. Firstly we want our "t" value defined in our model onto columns, then our newly created "Curve" calculation onto rows as shown below:

Sankey Chart Tableau

We now need to add a unique identifier onto detail to produce our curves. In my case, this is the Name of the player. Before moving on, make sure your chart type is set to "Line".

Sankey Chart Tableau

Now you should see what resembles a Sankey, and we need to add some colour to differentiate the various flows. To do this, I have added Nation onto colour.

Sankey Chart Tableau

A Sankey can have many uses, the most common of them being personnel and their flow within an organisation. I have shown a use case for players featured within the European Championship flowing from their Nation to their Domestic League then to their Domestic Club, as you can see in the dashboard below exploring the stats behind the nations in the upcoming Euro 2016 tournament. 

Ryan Smith

About the author

Ryan Smith is a Graduate Analytics Consultant at Concentra. He studied Computer Networks at the University of Portsmouth and has a love of all things technical combined with a growing love of data. He believes that, together, these two can bring great insights into fascinating and exciting areas of everyday life. Sports is his main passion, and he enjoys visualizing all types of data from Football to MotoGP.