Sankey Diagram
  • 02 Aug 2022
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Sankey Diagram

  • Dark
    Light

Overview

A Sankey Diagram is a flow diagram that conveys the relative size of metric data based on the size of flow lines from a source to a target.

In this walkthrough, we will create a sankey diagram that conveys the population of two world regions with flow lines to their respective countries.

Reference Content

The following articles may be useful resources as you build your chart:

  • Creating a Chart: A walkthrough of the overall process of chart selection and creation.
  • Using Preset Explore: How to work with the Explore page, the primary interface used when creating a chart.

Step 1: Create New Chart

To create a bar chart, in the Toolbar, select + Chart.

The Create a new chart screen appears.

In the Choose a Dataset field, select a dataset to build your query from. In this case, we are selecting a dataset that includes world population data.

Select All charts and then select a Sankey Diagram in the chart gallery. Alternatively, enter sankey in the search field.

Next, select Create New Chart.

Create_a_Sankey_Diagram.png


Step 2: Configure the Chart

Time Panel

Reference: How to Configure the Time

The first step is to define the Time Column field. This field contains a time-related column from the dataset. More than likely, this field is pre-populated for you.

You can recognize time columns by looking in the Columns listing in the Metrics & Columns panel and finding those with a small clock icon.

In this example, there is only one time column available, so there is no need to make any changes to the Time Column field.

Next, let's configure the Time Range field.

This field is used to specify a date & time range from which data will be extracted for the query. Generally-speaking, if you're working with a small dataset size, then it is best to use the No filter option (i.e., use all available data). If the dataset size is larger, though, then a date & time range is more appropriate.

In this case, we will not filter by time, so we'll select No filter.

Our completed Time panel looks as follows:

Bar_Chart_Time_Panel

Query Panel

For this diagram, our source will be a region and our target will be a country. We will select a metric that inludes total population values. Lastly, we'll filter by two regions: Europe & Central Asia and Middle East & North Africa. We will also limit rows to 20 in order to ensure diagram readability.

Let's start by dragging & dropping the region and country columns, respectively, into the Source / Target field.

In the Metric field, we will drag & drop the total population function included in the dataset (i.e., sum_SP_POP_TOTL).

Sankey_Diagram_Configure_Query

Next, let's configure the filter. We will filter by two regions: Europe & Central Asia and Middle East & North Africa.

Drag & drop the region column to the Filters field.

A sub-menu appears. By default, the region operator is "in" which works perfectly for our requirements. In the text field, select Europe & Central Asia and Middle East & North Africa. If desired, you can enter a search term and then select the matching option.

Sankey_Diagram_Configure_Filter

In the Row Limit field, select 20 — if you don't see "20" as an option, then enter the value 20 and then select in the drop-down.

This field is used to limit the number of columns that appear in the chart — if this number is set too large, then the sankey diagram will be unreadable. So be sure to experiment with some values to find the Row Limit that works best for you.

In the Sort by Metric field, enable the checkbox to sort results by the total population metric.

The completed Query panel looks as follows:

Sankey_Diagram_Query_Panel


Step 3: Run the Query

Reference: The Content Panel

Select Run or, in the Content panel, Run Query.

Run_Query

The sankey diagram appears in the Content panel.

Sankey_Diagram_Ran_Query

Most Preset charts are interactive, so feel free to hover your cursor over different elements of the visualization to get more data.

Additionally, you can expand the Data section to view data results and samples from the query.


Step 4: Finalizing the Chart

If you're happy with the visualization, be sure to give it a name:

Enter_Chart_Title_Here

If you'd like to customize your visualization, select the Customize tab.

Lastly, be sure to save your chart. Remember that you can also save your chart to a dashboard—or create a brand new dashboard—directly from the Save menu!

Here's a look at our finalized sankey diagram:

Sankey_Diagram_Finalized


Was this article helpful?