As helpful Sankey charts are in helping improve the overall data visualization and energy flow, the same is not the easiest to create. There are certain tools that can make the process easier for you for if you are using Tableau, chances are that you will be able to overcome the process quite easily.
But, there are complications to that as well and there are chances that you will be confused amidst the process. That doesn’t mean that you can’t get the desired results from the same. To help you create the Sankey diagram on Tableau, we have sorted out some of the easy steps that you need to keep into consideration.
Keep in mind that the process is lengthy and it is going to be confusing. But, following through each and every single step can help clear the doubts and get the desired results in the end.
What is a Sankey diagram?
Before we share the steps, let us brief you on what Sankey diagram is. It is a energy flow diagram which helps in providing a clear illustration of the flow of the energy involved in a process.
It can very well include any element of energy or even money and finance flow in a process. It depends on what one needs to visualize.
What is Tableau?
With Sankey diagram of the out way, let us talk about Tableau. Tableau is an online data visualization software that helps in better understanding and layout of your database in a diagrammatic form.
This helps in better understanding of the loopholes and the roadblocks that need to be mended.
It was Jeffrey Shafer from the Tableau community who piloted the techniques for drawing a Sankey chart in Tableau. Later, it was Olivia Katherine who worked further on the same and expanded on it for better efficiency. Even Chris Love further perfected the steps made by Noah Salvaterra and Joe Mako that made this process complete and wholesome.
- Also read: How to create Sankey diagram in Excel?
Steps to follow for drawing Sankey chart using Tableau
To be honest, there are several sections and roundabouts when it comes to making a Sankey chart using Tableau but we are going to give you a complete rundown of all the steps one after the other that you need to follow.
It is a lengthy one but trust us, if you follow through them blindly, it won’t be a difficult process for you. Just ensure that you have a basic coding knowledge and know how to use Tableau.
- Open Tableau.
- Select your excel file from the desired location on your computer. You can import it accordingly
- Drag your data sheet (which you want), and you will want to make a copy of the available data because that is how it demands to be done on Tableau to compensate for the both hands of the chart.
- Navigate to Data > Convert to custom SQL. A pop-up window will be displayed.
- In the pop-up window, copy and paste the code below it. Write UNION ALL in between the two codes
- In the first code, write “Segment” as VizSide before FROM keyword
- In the second code, write “Region” as VizSide before FROM keyword
- Click OK
- Now, navigate to Sheet 1, at the bottom
- Right click on the Measure section and click on Create calculated field. Then, name it as “ToPad”
- Now paste the following code: IF [VizSide]= “Segment” THEN 1 ELSE 49 END
- Click OK. ToPad menu will be displayed in the Measure section. (The reason why “49” is specifically used is because Jeffrey Shafer suggested that this arbitrary number is beneficial in helping form that swish curve line that is significant in the Sankey chart.)
- Drag ToPad to the Columns in the right hand side
- Hover it and an arrow will be displayed. Click on it.
- Select Dimension. Repeat step 11 and select Discrete.
- Drag the ToPad from column to the left hand side and it will disappear from column section
- Navigate to ToPad > Create > Bins
- Rename New field name as Padded. Size of bins as 1. Click OK. It will be shown in Dimension section
- Right click on Measure section and click on Create calculated field. Name it as t.
- Now paste the following code: (INDEX()-25)/4
- Click OK. t menu will be displayed in the Measure section
- Drag t to the Columns in the right hand side
- Hover it and an arrow will be displayed. Click on it.
- Select Discrete. Repeat step 11 and select Continuous.
- Drag Padded from Dimension section to Marks section
- Click on t and navigate to Compute Using > Padded
- Right click on Measure section and click on Create calculated field. Name it as Rank 1
- Now paste the following code: RUNNING_SUM(SUM([Sales]))/TOTAL (SUM([Sales]))
- Click OK. Rank 1 menu will be displayed in the Measure section
- Click on Rank 1 menu and select Duplicate. Rename it as Rank 2
- Right click on Measure section and click on Create calculated field. Name it as Sigmoid
- Now paste the following code: 1/(1+EXP(1)^-[t])
- Click OK. Sigmoid menu will be displayed in the Measure section
- Right click on Measure section and click on Create calculated field. Name it as Curve
- Now paste the following code: [Rank1]+(([Rank2]-[Rank1])*[Sigmoid])
- Click OK. Curve menu will be displayed in the Measure section
- Drag Curve to the Rows in the right hand side
- Drag Segment and Region to the Marks section in the right hand side
- Click on Curve(in the Rows section, in the right hand side) and click Edit table Calculation
- Select Rank 1 in Nested Calculation and click Specific Dimension
- Rearrange: Segment, Region, Padded. Check all the boxes
- Select Rank 2 in Nested Calculation and click Specific Dimension
- Rearrange: Region, Segment, Padded. Check all the boxes
- Right Click on the chart area. Click Format
- Select Line icon and change Grid lines and Zero lines to none
- Click on the BottomRuler of the graph
- Click Edit Axis
- Check Fixed. Set Fixed start : -5 and Fixed end : 5.
- Click on the Left side Ruler of the graph
- Click Edit Axis
- Check Fixed. Set Fixed start : 0 and Fixed end : 0. Check Reverse in Scale section
- Click on the Left side Ruler of the graph
- Uncheck Show header
- Click on the BottomRuler of the graph
- Uncheck Show header
- Close Format lines in the left hand side
- Drag Padded from Dimension section to Marks section
- Select Line in Marks section
- Navigate to Analyze > Create Calculated field. Rename it as Sales Sizing
- Now paste the following code: WINDOW_AVG(SUM([Sales]))
- Click OK. Sales Sizing menu will be displayed in the Measure section
- Drag Sales Sizing from Measure section to the Marks section in the right hand side
- Click on SalesSizing (in Marks section) and Compute Using > Padded.
- You can change the color of segment, region, padding as per your choice, by clicking on the left icon of each in the Marks section.
As complicated as the process seems, trust us, it only requires for you to follow through the steps. The process can take some time but make sure that you follow the steps as mentioned. Once the chart is completed, it is completely on you how you manage and customize the same. This is a very basic breakdown on how to draw a Sankey chart using Tableau.