How to Build a Sankey Chart in Tableau + a Euro 2016 Viz You Can't Miss
To find out more about Concentra's bespoke Analytics Services and Solutions see Services.
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).
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.
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.
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.
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:
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".
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.
A Sankey can have many uses, the most common of them being personnel and their flow within an organization. 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.