Sankey Diagram Data Structure: A Complete Guide

Data structure is an important step before creating a Sankey diagram. There are two common approaches: describing individual connections between nodes or storing complete paths across multiple stages.

Both approaches can produce visually identical Sankey diagrams. However, depending on how the data is structured, the information available for further analysis can be significantly different. In this guide, we explore both data structures, how to convert between them, and why the choice matters when moving beyond visualization into flow and journey analysis.

Two Common Sankey Diagram Data Structures

Sankey diagrams can be constructed from several types of datasets, but two particularly common input structures are:

  • Source–target–value format: Each row represents an individual connection between two nodes.
  • Multi-level format: Each row represents a complete sequence across multiple stages, with an associated value.

The first approach describes connections. The second describes how records are related across multiple levels. Both are useful, but they organize information differently.

Source–Target–Value Data Structure

The source–target–value format is one of the most widely used input structures for Sankey diagrams.

It typically consists of three columns:

SourceTargetValue
RevenueGross Profit600
RevenueCost of Revenue400
Gross ProfitOperating Profit350
Gross ProfitOperating Expenses250

Each row defines a connection, its direction, and the quantity associated with it. Depending on the application, these columns may also be called From, To, and Amount, or Source, Destination, and Weight.

When Should You Use This Format?

The source–target–value structure is especially suitable for:

  • Income statements and financial reporting.
  • Energy and material flows.
  • Budget allocation.
  • Resource distribution.
  • Relationships between individual categories.

In these applications, the connections themselves often contain all the information needed for the visualization. The format is compact, flexible, and does not require every flow to pass through the same number of stages.

Multi-Level Sankey Diagram Data Structure

A multi-level data structure organizes information into successive columns, with each row representing a complete path through the dataset.

Consider the following accounts receivable example:

IndustryPayment TermsCollection ChannelPayment StatusAmount
AutomotiveNet 30Auto EmailPaid On Time4,700
HealthcareNet 30Phone OutreachOverdue 90+d2,500
Financial ServicesNet 60Auto EmailPaid On Time3,200
RetailNet 30Auto EmailOverdue 90+d1,800

Instead of describing individual connections, each row preserves the relationship between all its stages. The final column contains the quantitative measure used to determine flow widths. This measure could represent revenue, invoice amounts, customer counts, transaction volumes, or another additive quantity.

When Should You Use This Format?

Multi-level data structures are particularly useful for:

  • Customer journey analysis.
  • Accounts receivable analysis.
  • Sales and conversion processes.
  • Operational workflows.
  • Manufacturing and quality control.
  • Multi-stage business processes.

When each row represents an observed journey, this format preserves information about the complete route, from its origin to its final outcome.

Converting Multi-Level Data into Source-Target–Value Format

A multi-level dataset can be converted into a source–target–value table by extracting connections between consecutive columns.

For example, consider a single record:

ChannelInteractionOutcomeValue
OrganicDemoConverted100

This record generates two connections:

SourceTargetValue
OrganicDemo100
DemoConverted100

The same operation can be repeated for every row in the original dataset. Identical connections can then be grouped, and their values summed. The resulting table contains the information required to construct a conventional Sankey diagram. However, an important question arises: can we reverse this transformation and recover the original journeys from the aggregated connections?

As the following example demonstrates, this is not always possible.

Sankey Diagram Example: Analyzing Payment Outcomes

Consider an accounts receivable dataset containing 720 records organized across seven levels:

  1. Industry
  2. Product
  3. Payment Terms
  4. Workflow Channel
  5. Collection Action
  6. Response Signal
  7. Payment Status

Each record also contains an amount representing its financial weight.

An aggregated Sankey diagram provides an overview of the relationships between these seven dimensions. However, additional analytical questions arise when investigating specific payment terms or collection outcomes.

For example:

What proportion of the Net 30 invoice volume ended up in the Overdue 90+d category?

Answering this question requires connecting the third level of the dataset with its seventh and final level, regardless of the intermediate routes.

sankey diagram data structure

Because the original dataset preserves complete paths, the result can be calculated directly from the observed records.

MetricObserved value
Total Net 30 volume816,070
Volume ending in Overdue 90+d158,180
Share of Net 30 volume19.38%
Share of total Overdue 90+d volume52.1%

Approximately 19.4% of the observed Net 30 volume ended in the Overdue 90+d category. This result does not require a Markov-based reconstruction or an assumption about how flows are distributed across intermediate stages. It is calculated directly from the records containing both the selected payment term and the specified final outcome.

Importantly, this percentage represents financial volume rather than the number of invoices or customers.

Exploring the Journeys Behind the Result

Preserving the original path information also makes it possible to investigate the complete journeys behind an aggregated node. In this example, the Net 30 node contains 257 distinct observed journeys with a combined weight of 816,070.

sankey diagram journey analytics and observed paths

Filtering Observed Journeys by Multiple Conditions

Preserving complete journeys also enables filtering across multiple stages simultaneously. In the previous example, we identified 158,180 units of Net 30 volume ending in the Overdue 90+d category. By applying both conditions to the original journey data, we can retrieve the exact paths contributing to this result.

MetricFiltered result
Matching observed journeys48
Matched volume158,180
Share of Net 30 volume19.4%
Share of the three largest matching journeys11.7%

Rather than estimating how flows may have reached a particular destination, the analysis identifies the journeys that satisfy both conditions in the recorded dataset.

Filtering Observed Journeys by Multiple Conditions

Additional conditions can further narrow the investigation to specific industries, products, collection channels, or intermediate actions. This illustrates a fundamental advantage of preserving complete paths: aggregated analytical results can be traced back to their underlying journey distributions.

Frequently Asked Questions About Sankey Diagram Data Structures

What data structure is required for a Sankey diagram?

The most common structure consists of three columns: source, target, and value. Many Sankey applications also support multi-level datasets in which successive columns represent stages and each row contains a complete path.

Can a Sankey diagram have more than two levels?

Yes. Sankey diagrams can represent multiple interconnected stages. The maximum supported number of levels depends on the visualization software and its layout implementation.

Can I convert multi-level data into source–target–value format?

Yes. Extract connections between consecutive stages, assign the relevant weight to each connection, and aggregate identical connections. Retain the original dataset if complete path information is required for further analysis.

Can original journeys be recovered from aggregated Sankey connections?

Not always. Different sets of journeys can produce identical aggregated connections. In some network structures, the decomposition may be uniquely determined, but this cannot be assumed in general.

Is the source-target-value format unsuitable for advanced analytics?

No. It remains highly suitable for analyzing direct relationships, resource distribution, network structures, and financial flows. Its limitations become relevant when analytical questions require associations across multiple stages that are not preserved in the aggregated data.