How to Make Sankey Diagram in Excel (With Detailed Steps)

What Is Sankey Diagram?

Sankey diagram is a flow diagram which is handy and effective when working with flow analysis. The width of the arrows is maintained by the quantities and values of the categories.

Any kind of flow analysis such as material flow, energy flow, cash flow, etc. can be visualized and analyzed through this diagram.


  • The biggest advantage of the Sankey diagram is you can visualize the trend of multiple categories of your data.
  • You can understand the relative weights of every category by the width of the arrows in the Sankey diagram.
  • You can portray many complex categories through the Sankey diagram.


  • It is hard to draw and understand sometimes due to its complex features.
  • If the arrow width of the two categories becomes the same, it becomes difficult to differentiate between them.

We have a sample dataset of a person’s income source and expenses. We’ll create a Sankey diagram showing how his different income sources cover his expenses.

Sample dataset to Make Sankey Diagram

Step 1 – Preparing Necessary Data to Make Sankey Diagram in Excel

  • Select the data range (B4:F8) >> click on the Insert tab >> Table tool.

Convert the Dataset into Table to Make Sankey Diagram

  • The Create Table window will appear. Click on the OK button.

Confirm the Creation of Table

  • Name your table.
  • Click inside the created table >> go to the Table Design tab >> enter Dataset inside the Table Name:

Name the Table

  • You need to specify the space between the two categories of the Sankey diagram.
  • Enter the value inside the D10 cell >> go to the Formulas tab >> Defined Names group >> Define Name.

Access the Define Name Option

  • In the New Name window, enter Space inside the Name: text box and click OK.

Create a Named Range to Make Sankey Diagram

Step 2 – Prepare Sankey Lines Table

  • Create a table named Lines containing From, To and Value columns.

Sankey Lines Table

  • Click on cell D5 and insert the following formula.
=IF(LEFT([@From],5)="Space",Space,INDEX(Dataset,MATCH([@From],Dataset[From / To],0),MATCH([@To],Dataset[#Headers],0)))
  • Press Enter.

Find Values of Sankey Lines from Data

  • As this is a table, all the cells below this column will follow the same formula and will be automatically filled.

All Values Extracted from Dataset

  • We have added some new columns and named them End Position, Astart, Amid1, Amid2, Aend, Vstart, Vmid1, Vmid2, Vend, Bstart, Bmid1, Bmid2, and Bend for obtaining values to draw the charts.

Create New Columns of Sankey Table

  • The values in the End Position column will be given according to column To and insert a space number after each category ends.
  • The first category is Rent in the To So, numbering will continue as 1,2,3,4 downwards for Rent and when all Rent is counted, Space 1 will appear and contain the next digit (5 here).

Finding End Position Value for Food Category

  • Food is the second category. It will contain end position numbers from 6. The numbering will increase as we go downward in the To column and find the Food When all the Food category is counted, Space 2 will appear and contain the next digit (10 here). This will go on until all the values of the To column are counted.

Finding End Position Value for Rent Category

  • To get the values of the other created columns, enter the following formula and press Enter.

Astart Column:


Amid1 Column:


Amid2 Column:


Aend Column:

=SUM([Value])-SUMIFS([Value],[End Position],">="&[@[End Position]])

Vstart Column:


Vmid1 Column:


Vmid2 Column:


Vend Column:


Bstart Column:


Bmid1 Column:


Bmid2 Column:


Bend Column:

  • Create another table for obtaining the source pillars.
  • Create two columns named From and Value in this table.

Source pillars Table

  • Click on the C28 cell and enter the following formula for source pillar values.
  • Press Enter.

Source Pillars values Extraction Formula

  • Create another table for destination pillars with two columns named To and Value.

Destination Pillars Table

  • Click on the C38 cell and enter the following formula.
  • Press the Enter button to get all the destination pillars’ values.

Destination Pillars Values

  • You will need spacing values of the X-axis to draw the diagram properly.
  • Enter the spacing values as 0, 10, 90 and 100 at C46, D46, E46 and F46 cells.

Spacing Values

You have all the values that you need to draw the Sankey diagram of your dataset.

Step 3 – Drawing Individual Sankey Lines in Excel

After getting all these values, you need to draw individual Sankey lines.

  • Click on the Insert tab >> Insert Line or Area Chart tool >> 100% Stacked Area.

Insert Chart to Make Sankey Diagram

  • A 100% stacked area chart will pop up.
  • Right-click on the chart area and choose the option Select Data… from the context menu.

Stacked Area Chart

  • The Select Data Source window will pop up.
  • In the Legend Entries (Series) pane, click on the Remove button to delete all the initial entries.

Remove Initial Entries

  • Afterward, click on the Add button.

Add Series to Make Sankey Diagram

  • The Edit Series window will pop up.
  • Enter 1 at the Series Name: text box >> choose the F5:I5 cells reference in the Series values: text box.
  • Click on OK.

Edit Series Window

  • In the Horizontal (Category) Axis Labels pane, click on Edit.

Edit Horizontal Labels to Make Sankey Diagram

  • The Axis Labels window will pop up.
  • Refer to the F46:I46 cells in the Axis label range: text box.
  • Click on OK.

Finalize Horizontal Axis values

  • Double-click on the Y-axis >> tick the option Values in reverse order from the Format Axis pane on the right side.

Reverse Order to Make Sankey Diagram

The Sankey lines are drawn.

Read More: How to Draw Lines in Excel

Step 4 – Adding Sankey Pillars to the Diagram

  • Select the B28:C34 cells >> click on the Insert tab >> Insert Column or Bar Chart tool >> 100% Stacked Column.

Insert Bar Chart to Make Sankey Diagram

  • In the stacked chart window, go to the Chart Design tab >> Change Chart Type.

Access the Change Chart Type tool

  • In the Change Chart Type window, choose the second option and click on OK.

Finalize your Chart Type

  • You will see your desired pillar which will be displayed like the following image.

Source Pillar to Make Sankey Diagram

  • Since you don’t need the space to be shown, click on the space area and choose the option No fill from the Format Chart Area pane on the right side.

Remove Fill from Space

  • You will get your final source pillar to make the Sankey diagram.

Final Source Pillars to Make Sankey Diagram

  • You can make pillars for destination sources and change their colors by choosing the Fill Color option from the Format Data Series pane on the right side.

Destination Pillars to Make Sankey Diagram

  • Combine these Sankey lines with the Sankey pillars to complete the Sankey diagram.

The final diagram will look like the image shown below.

Sankey Diagram in Excel

Read More: How to Draw to Scale in Excel

Understanding a Sankey Diagram

Sankey diagrams can easily portray the sources, destinations and contributing pathways from sources to destinations.

Understanding the Sankey Diagram

Generally, the sources are situated on the left side and the destinations are on the right. From the sources to destinations, several pathways are drawn to depict the tradition and contribution of each source and destination. Besides, the width of these pathways helps to visualize the greater and lesser contribution of pathways.

Read More: How to Make Fishbone Diagram in Excel

Download Practice Workbook

Related Articles

<< Go Back to Drawing in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Tanjim Reza
Tanjim Reza

Md. Tanjim Reza Tanim, a BUET graduate in Naval Architecture & Marine Engineering, contributed over one and a half years to the ExcelDemy project. As an Excel & VBA Content Developer, he authored 100+ articles and, as Team Leader, reviewed 150+ articles. Tanim, leading research, ensures top-notch content on MS Excel features, formulas, solutions, tips, and tricks. His expertise spans Microsoft Office Suites, Automating Finance Templates, VBA, Python, and Developing Excel Applications, showcasing a multifaceted commitment to the... Read Full Bio

  1. D5 formula does not work. The syntax of the name “@To” isn’t correct. Verify the name: -starts with a letter or underscore, – Doesn’t include a space or character that isn’t allowed. – Doesn’t conflict with an existing name in the workbook.

    • Hello James,
      Thank you for your query.
      Regarding your problem, I can assure you that the formula in cell D5 is correct. The syntax “@To” is not a common syntax, this is right. It is actually a dynamic table formula syntax. When you work with dynamic table formula, then to look up certain column values, you have to use this syntax. Even, if you select a cell of a table column inside a table, you will see the formula would automatically pick this syntax. I hope this answers your question.
      Again, to assure you, the formula in cell D5 is working correctly in my file. But, if you keep facing issues regarding this formula, I would really appreciate it if you send me your Excel file. Maybe I can help you further then!
      Thank you!

      Md. Tanjim Reza Tanim
      Team Leader, Exceldemy.

  2. I have completed all the other steps but am confused by the ‘end position’ column in the lines table. I do not see a step which tells me what to enter into this column, which is an issue for the other formulas.

  3. I have completed all the other steps but am confused by the ‘end position’ column in the lines table. I do not see a step which tells me what to enter into this column, which is an issue for the other formulas.

      End Position is given according to column To. Where there is RENT in To column, the number starts 1,2,3,4 and ends with SPACE1 numbered 5. Then next is Food starting 6,7,8, 9 and ends with SPACE2 numbered 10. Likewise, numbering is done for every cell data in End Position.
      Numbering End position
      Joyanta Mitra

Leave a reply

Advanced Excel Exercises with Solutions PDF