Equal Width Sankey - Tableau Prep Template
Updated: Jul 11
All credit for the original template, workbook and method goes to Ken Flerlage and Kevin Flerlage. Thanks for letting me create this!
Prep Template Build Video: Equal-Width Sankey Tableau Prep Template: Put Some Prep in Your Step - YouTube
I love a good sankey chart. They can be really effective and visually stunning in the right application. I've rarely had a scenario where it was the right chart type in a business setting, but it has happened. Even with all of the wonderful "How to build a sankey in Tableau" resources out there, it can still be a challenge to get the data in the right format.
If you've been following this series, you know that's the purpose for these Tableau Prep templates. If you are new, then this is the high-level summary:
There are plenty of workbook templates with pre-built calculations for visualizations that aren't out-of-the-box in Tableau. Most of those templates require the data to be structured or pre-aggregated a very specific way. This template, as well as the other Prep templates, are to help you take your real-world data, plug it in, and get it in the correct structure to easily plug in to some workbook templates.
Today we're going to take a look at structuring data to fit into the Equal Width Sankey template created by the Flerlage Twins. Their blog post is extremely detailed as far as how the calculations work inside Tableau, so if you'd like to know those details, check out their original post (Equal-Width Sankey: A New Approach to Drawing Sankey Curves (with a Tableau Template) - The Flerlage Twins: Analytics, Data Visualization, and Tableau)
Part of the usefulness of these Prep templates is that they do require a little bit of choosing columns and renaming which will help you get familiar with Tableau Prep. Aside from that, the pre-built pieces of the flow do the heavy lifting so you can spend more time visualizing the data!
You can find the Prep flow and the Sample - Superstore data set (if needed for demo purposes) here: Equal Width Sankey - Google Drive
The Data Previously, we kept the original format of the Tableau templates, using an already structured table as our input. This time, we're going to handle all of that in Prep.
We will be working with the Orders sheet in the Sample - Superstore data set for this walkthrough:
This is meant to show that this template will work with any row-level data set, you just have to define what columns are needed for your chart.
In the original post, the data is structured like this:
The great thing about this template is that it will allow you to easily add or remove levels. If you only need the sankey to flow from one dimension to another, then just pick 2 columns to be your Step 1 and Step 2.
If I want the data to flow from Segment to Category, I would rename Segment to Step 1 and Category to Step 2. This will give me the following result when plugged in to the workbook:
This is what the pre-built portion of the Prep flow looks like.
First you will connect to your data source and drag your table to each of Scaffold Range and Remove/Rename steps.
The Remove/Rename field won't have any changes in it initially. You will use this step to remove everything you don't need. This is where you have to make some decisions. How many levels do you want your sankey to be? If you want 2 levels, you need 3 steps. If you want 3 levels, you need 4 steps. Each step is a column so in this example we're following this flow: Segment → Category → Sub-Category → Ship Mode → Region
This becomes: Step 1 → Step 2 → Step 3 → Step 4 → Step 5
We also need to pick a measure that we want to visualize flowing through these steps. I'm going to use Sales, which will become the Size field. First, I select the fields I'm going to need for this chart and remove everything else.
Then I reorder and rename the fields to match the original excel template structure
From here, if you used 5 steps, the Prep flow does the rest of the work for you. If you used less than 5 steps, you may get some errors in the Data Sheet step. For example, if you used 3 steps, you'll see this:
All you need to do is remove the steps with the errors. If you used more than 5 steps, you'll need to drag those fields into the Grouped Fields pane for them to be a part of your data.
Next you'll download the Equal Width Sankey workbook from here: Equal-Width Sankey Template | Tableau Public Connecting to the Data
Open the workbook and go to any sheet and add a new data source.
We're going to replace the original data source with our prep output, but first we need to make some changes to ensure a smooth swap. In the original data source, the Size column is a whole number and in our output its a decimal number. Change the type of the original size column to decimal.
Also in the original data source, the Path field is a dimension. We're going to drag the Path field in our new data source to Dimensions
Finally, you'll replace the data source:
All of the calculations will transfer over, and you've got a Sankey!
If you used less than 5 steps, you'll need to remove some sheets and if you used more, you'll need to copy some calculations and add sheets to get that to work properly. Ken outlines this in the original blog post.
I hope you are able to make use of this Prep template! If you'd like to learn how it was built, check out the video here: Equal-Width Sankey Tableau Prep Template: Put Some Prep in Your Step - YouTube