In today's data-driven world, visualizations play a key role in helping us make sense of complex information. One of the most insightful tools for representing the flow of resources, energy, or information between different points is the Sankey chart. Named after Captain Matthew Sankey, who first used it to illustrate the energy efficiency of a steam engine, this chart has become a popular way to showcase proportional flows across various industries.
Whether we're tracking energy consumption in a facility, mapping financial flows, or analyzing any process that involves distribution, a Sankey chart allows you to quickly identify bottlenecks, inefficiencies, and major trends. In this blog post, we’ll dive into what a Sankey chart is, how it works, and why it’s a powerful tool for visualizing complex systems.
In healthcare, Sankey charts are used to visualize complex flows of resources, patients, or processes. They help provide clear insights into how various healthcare components interrelate. Some specific ways in which Sankey chart is used in healthcare are for patient flow analysis, healthcare resource allocation, patient treatment and outcomes, public health and epidemiology, etc.
In sepsis, I have created a Sankey chart, to visualize the flow of patients between age and gender in SIRS stage.
Step 1 -
To create the above Sankey chart we need copies of our data. One for the gender on the left hand side of our chart, and another for the age on the right hand side. Union the data to itself to get these two copies.
Once unioned, Tableau will create a new field called ‘Table Name’. This field, and it’s contents, will be used in calculations later on.
Step 2 -
Create a new calculated field, ToPad. This calculated field will mean that one copy of our data will be labelled 1 and the other 49.
Step 3 -
Create bins on the ToPad field, with bin size as 1. This will simulate values between 2 and 48.
Step 4-
Create a new calculated field, T. This field will ensure the marks are spread out across the view.
Step 5 -
Add the calculated field ‘T’ to the columns and add ‘Padding’ to the details shelf. Then change the mark type to a circle.
Step 6 -
Right click on the T field and select 'Compute Using ' -->'Padding'. This will show all the marks
Step 7 -
Create a new field called Rank 1. Duplicate this to create another field called Rank 2. These calculations will inform Tableau where the lines of the chart should start and end.
Step 8 -
The signature s-shaped curve of a Sankey chart is called a sigmoid curve. Create a calculated field that will show Tableau how to draw the s-shaped curve.
Step 9 -
Using the already calculated fields, we need to create one calculation that builds the curve of the chart.
Step 10 -
Add the Curve field to the rows shelf. Add the Gender and age to the details shelf. Right click on the Curve pill and select edit table calculation. Select Compute Using Specific dimensions, using the dimensions specified below, in that order. Also, use the T in nested calculations and compute using specific dimensions, Padding.
Step 11 -
Adjust the x-axis from -5.5 to 5.5 and y-axis from 0-2 (reversed).
Step 12 -
Hide the headers.
Step 13-
Change the marks type to Line and Padding field is on the path shelf. Then the lines start to appear. To adjust the sizing of the lines, create a calculated field Sizing.
Add this calculation the Size shelf and compute using 'Padding'.
Here 't2_sirs patients' is the total count of patients having SIRS.
Step 14 -
Add the Gender to color. The central curve for the Sankey chart is ready,
Step 15 -
In two separate sheets, create two stacked bar charts, one for gender and other for age ranges.
Step 16 -
Now combine the three sheets into a dashboard for the final Sankey chart. Here we can format the sheets and title accordingly.
I hope this helps you in understanding how to create and use Sankey charts.
As you dive into your own data and insights, remember that every visualization brings clarity to your story. Whether you're just starting or refining your skills, keep experimenting and pushing boundaries.
Happy visualizing, and may your data always tell the story you discover! Feel free to share your experiences or thoughts in the comments below. Thank you for reading!
References: