It seems 3-stage Sankey chart is a popular one. I think it's worthwhile to create a monolithic template like the minimal Sankey template. It takes only a few simple steps in a few minutes to quickly create a 3-stage Sankey chart. It will save you a lot of time. I hope this will make everyone a creator of the curvy Sankey chart. I need to acknowledge that this template is inspired by the original contributions of Jeffrey Shaffer, Olivier Catherin and Ken Flerlage.
Three Steps
So here you go a new tutorial on building 3-stage Sankey chart in Tableau. It takes 3 main steps:- Import your data into the template and union the data set with itself.
- Rename Stage1/2/3 and Size in the template according to the 3 dimensions and 1 measure in your data set.
- Replace template data source by your data set. Resize the dashboard components to make appear the labels, if necessary.
More details please refer to the video tutorial.
Template Screenshot
Sankey chart on Grand Prix below is created using the above template.
Caveat
In the 2020.1 version of Tableau, there is a glitch in replacing data source. We may need an extra step by "Replacing References". See video tutorial for more details.That's it. Feel free to download the template and create your own Sankey chart. Please leave questions in the comment area if any. Enjoy Sankey!
Sankey Chart Series in Tableau
5.A Template Approach to 3-Stage Sankey Chart
3.Creating Sankey Chart with Grouping
2.Creating Multi-Stage Sankey Chart via Template Cascading
1.Creating Sankey Chart Made Easy via Template
Hi Alex, thanks for creating this template! I followed all the steps and successfully replaced the data source and calculation references, but I'm having trouble with the "Path (bin)" field. I get an error (red !) saying the calculation is invalid. How is this field computed? I thought maybe you binned the "size" measure, but trying that yielded a range of 0 to 22,638 not 0 to 97.
ReplyDeleteIt’s binned on the field Path. Did you union the data source first?
DeleteOh, that must be the issue - there is no field "Path" in the template you linked (https://public.tableau.com/views/3-StageSankeyTemplateinTableau/3-StageSankeyTemplate?:display_count=y&:origin=viz_share_link&:showVizHome=no). Yes, I unioned the data first (via custom sql - I hope that's ok).
DeleteWhen using custom sql, did you create an extra field ‘Table Name’ to denote upper and lower tables differently? Say, table1 and table2. That’s crucial to the data union.
DeleteI did create a dimension for that purpose, but didn't call it "Table Name" - I'll rename things to match your suggestion. Will that solve the issue of the missing "Path" field though?
DeleteYes. It will solve the problem. Don’t worry about Path. It’s hidden.
DeleteI wrote here about how to union in sql http://vizdiff.blogspot.com/2018/12/creating-sankey-chart-as-easy-as-1-2-3.html
DeleteThat solved the issue! Thanks so much for talking me through this, Alex!!!
DeleteSo glad you made it to work. Your table fields have to match those in the template exactly!
ReplyDeleteHi Alex, this template is very easy to use! I'm wondering how do I change the colour of the arms so that (in the example above) - if Furniture is pink, I want all the arms coming out of furniture to be pink and follow through to the end in the same colour. I tried putting Stage 1 in Colour in the Marks card but it broke the chart. Thanks
ReplyDeleteThe pink part is going to the East region. From East to the end, we need to use a composite dimension like stage1+stage2+stage3 to highlight or color the the arms.
DeleteTry this one for any number of stages: https://vizdiff.blogspot.com/2020/01/creating-3-stage-sankey-chart-via.html
ReplyDeleteHi, thank you for this template! Is it possible to show size as a % of the source rather than target?
ReplyDeleteE.g. 25% of furniture orders come from the central region rather than 30% of central region orders are furniture
Just added both sizes per source and per target to the template. Check it out and see if it works for you.
DeleteThank you for the excellent template. I was wondering if there is any way to create this Sankey charts with some missing data on the second and third stage. I am trying to plot some kind of divergence pattern from the first stage to second stage, and from second stage to third stage. But some of the groups does not diverge at second or third stage, when i provide the input, i have tried not to fill anything in the second/third stage or putting NA, all does not works well. And finally i have tried to use the exclude function of tableau to remove the accumulated "empty bar", but the intermediate curvy line did not change accordingly. Could you kindly help on this?
ReplyDeleteCould you try this cascading approach? http://vizdiff.blogspot.com/2020/01/creating-3-stage-sankey-chart-via.html
DeleteHi Alexander, thank you so much for your response to my inquiry. I have read through your post in http://vizdiff.blogspot.com/2020/01/creating-3-stage-sankey-chart-via.html but not sure how this will help with my problem. I have uploaded the sankey graph I generated and the raw txt file and your template file to the following link: https://www.dropbox.com/sh/ufpsrea2rfucjvz/AACAZPR1yCi5aTEJHxJc2T3Oa?dl=0 . My problem is that some of the items in the first group do not need to have any divergence to the second group, and some of the second group do not need to have any divergence to third group as well. But I am not sure how i can accomplished this, as the current graphs will just group all the empty cells into a independent bar in the graph. I needed this template to work so much, i appreciate for your help. Thank you in advance
Delete1.Yes try grouping as described here https://vizdiff.blogspot.com/2020/01/creating-sankey-chart-with-grouping.html
Delete2.Try set the color to be white for those branches you want to hide.
See if this solves your problem.
Looked into the files you shared. If you can draw a picture of the expected outcome, it would be greatly helpful. Hand drawing is fine.
DeleteHi Alex, so thrilled to have found this template! My version of Tableau is 2020.4.13, so after following all the steps I still have "Bar Position" and "FlowSize" broken (calculation invalid). Any instructions on how to fix it?
DeleteCould you send me the workbook? alexandermou2000 at gmail
DeleteHi.
ReplyDeleteFirst of all, thank you for explaining in detail how to apply a simple raw chart.
Is there a simple way to change from a 3STAGE template to a 4STAGE template?
Please refer to this technique on building 4-stage or more Sankey chart. https://vizdiff.blogspot.com/2020/01/creating-3-stage-sankey-chart-via.html
DeleteThank you for this great template! I am running into a problem with dropping the sigmoid polygons onto the worksheets- any suggestions as to what I am doing wrong? Thank you again!
ReplyDeleteCould you contact me at https://www.linkedin.com/in/alexmou/ ?
DeleteTry put "Path(bin)" on the Rows shelf first. Then right click on it and turn on "Show Missing Values". Last, move it from Rows to Details shelf. See if this works for you.
Delete