How to create a Sankey chart in Power BI: step by step
This tutorial shows how to create a Sankey chart in Power BI to visualize flows between categories (for example, source→destination). A Sankey helps understand where losses or transfers occur between stages and is useful in funnel analysis, product movements or user journeys.
Prerequisites
- Power BI Desktop installed (up-to-date version)
- Data with source, destination and value columns (CSV or Excel)
- Internet connection to install a custom visual (optional)
Step 1: Prepare the data
The Sankey requires a table with at least three fields: Source, Target and Value (flow amount). Create a CSV/Excel file with rows that represent each flow. Minimal example:
Source,Target,Value
Website,Trial,120
Trial,Active,80
Trial,Churn,40
Website,DirectPurchase,30
DirectPurchase,Active,25
Import this file into Power BI: Home > Get data > Text/CSV or Excel. Load the data to the model (Load).
Step 2: Clean and model the data in Power Query
Open Power Query (Transform data) to ensure types are correct: Source and Target as Text; Value as Decimal/Whole Number. Remove blank rows and null values. If there are duplicates of Source-Target pairs, aggregate by summing Value to reduce cardinality, which is important for the Sankey visual performance.
// Example M transformation (Group By) // In Power Query use: Home > Group By let
Fonte = Csv.Document(File.Contents("fluxos.csv"),[Delimiter=",", Columns=3, Encoding=65001, QuoteStyle=QuoteStyle.None]),
Promoted = Table.PromoteHeaders(Fonte, [PromoteAllScalars=true]),
Changed = Table.TransformColumnTypes(Promoted,{{"Source", type text}, {"Target", type text}, {"Value", Int64.Type}}),
Agrupado = Table.Group(Changed, {"Source","Target"}, {{"Value","Sum","each List.Sum([Value])"}})
in
Agrupado
Step 3: Install and add the Sankey visual
Power BI does not include a Sankey visual by default, so install a certified visual from the marketplace: Visualizations > ... (Get more visuals) > search for “Sankey” and install one (e.g.: "Sankey (by Microsoft)" or another certified one). After installing, drag the visual onto the page.
Step 4: Configure the visual fields
In the Fields pane of the Sankey visual, drag Source to Source/From, Target to Target/To and Value to Weight/Value (names vary depending on the visual). The visual will render the links; if it does not appear, check types and positive values.
Step 5: Improve readability
Sort and filter to avoid overloading the chart. Use slicers or filters to reduce dimension (e.g.: period, region). Adjust colors and labels in the visual properties to show Value on the links and names on the nodes. If the visual supports it, enable tooltips to see details on hover.
Step 6: Create a sample measure (optional)
If your data has multiple rows per flow with a Date column, you can create a measure to sum Value filtered by period. Simple DAX example:
Total Flow = SUM('Fluxos'[Value])
Use this measure in the Value field of the Sankey if the visual accepts measures (not all accept measures and some require an aggregated column).
Step 7: Common errors and how to fix them
- Empty chart: confirm there are positive values in Value and that Source/Target do not have nulls. - Duplicate nodes with different spellings: standardize text in Power Query (trim, lowercase) - Slow performance: aggregate Source-Target pairs and reduce cardinality; filter data by period or sample
Verify the result
Validate that each link shows the correct value and that totals make sense (the sum of outputs from a Source should match the sum of inputs to the Targets). Use a card or simple table with SUM(Value) by Source and by Target to compare numbers. Hover over the flows to see tooltips with details.
Conclusion
You now have a functional Sankey chart in Power BI that lets you visualize flows between categories. Next steps: add more filters, incorporate Date for temporal animation (using the Play Axis visual) and combine with other visuals for context. Tip: start with aggregated data to validate the logic before scaling to the full dataset.