Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
snehasissamal
Frequent Visitor

Sankey Chart Data model Preparation

Hi,

I want to have a Sankey chart to display the budget Sector -> Directorate - Expenditure type i.e 2 level one

 

How I can create a table to get the data in proper format for Sankey chart from original data. We are reading data from Excel sheet.

 

Adding the actual data format, required Sankey data format, and the expected chart. Kindly help me to build the DAX query to create dynamic calculated table so that I can bind it to Sankey chart.

 

Thanks in advance!!

 

 

Original DataOriginal DataREquired data format for Sankey ChartREquired data format for Sankey ChartSample Sankey ChartSample Sankey Chart

 

Original Data

YearSectorDirectorateDescriptionExpenditure TypeEstimated Budget
2024Sector ADirectorate AA1Project 1Locked10000
2024Sector ADirectorate AA1Project 2Spent2000
2024Sector ADirectorate AA1Project 3Remaining8000
2024Sector ADirectorate AA2Project 4Locked5000
2024Sector ADirectorate AA2Project 5Remaining2000
2024Sector BDirectorate BB1Project 6Locked50000
2024Sector BDirectorate BB1Project 7Spent25000
2024Sector BDirectorate BB1Project 8Remaining25000
2024Sector BDirectorate BB2Project 9Locked100000

 

Required data format 

SourceTargetBudgetLevel
Sector ADirectorate AA1200001
Sector ADirectorate AA270001
Sector BDirectorate BB11000001
Sector BDirectorate BB21000001
Directorate AA1Locked100002
Directorate AA1Spent20002
Directorate AA1Remaining80002
Directorate AA2Locked50002
Directorate AA2Remaining20002
Directorate BB1Locked500002
Directorate BB1Spent250002
Directorate BB1Remaining250002
Directorate BB2Locked1000002

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from @lbendlin , please allow me to provide another insight: 

 

Hi  @snehasissamal ,

Here are the steps you can follow:

1. Create calculated table.

True Table=
var _table1=
SUMMARIZE('Table',[Sector],[Directorate],"Budget",
SUMX(FILTER(ALL('Table'),[Sector]=EARLIER('Table'[Sector])&&[Directorate]=EARLIER('Table'[Directorate])),[Estimated Budget]),
    "Level","1")
var _table2=
SUMMARIZE(
    'Table',[Directorate],'Table'[Expenditure Type],"Budget",
    SUMX(
        FILTER(ALL('Table'),
        [Directorate]=EARLIER('Table'[Directorate])&&
        [Expenditure Type]=EARLIER('Table'[Expenditure Type])),[Estimated Budget]),
        "Level","2")
return
UNION(
    _table1,_table2)

2. Result:

vyangliumsft_0-1717141377851.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi  @snehasissamal ,

 

You might consider using the Original Data table's [Year ] and [Sector] as slicers and then using measure to filter.

Here are the steps you can follow:

1. Create measure.

Flag =
var _selectyear=SELECTEDVALUE('Original Data'[Year])
var _selectsector=SELECTEDVALUE('Original Data'[Sector])
var _test=SELECTCOLUMNS(FILTER(ALL('Original Data'),'Original Data'[Year]=_selectyear&&'Original Data'[Sector]=_selectsector),"Test",'Original Data'[Directorate])
return
IF(
    MAX('True Table'[Sector]) in _test || MAX('True Table'[Directorate]) in _test,1,0)

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1717548992033.png

3. Result:

vyangliumsft_1-1717548992039.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

Thanks for the reply from @lbendlin , please allow me to provide another insight: 

 

Hi  @snehasissamal ,

Here are the steps you can follow:

1. Create calculated table.

True Table=
var _table1=
SUMMARIZE('Table',[Sector],[Directorate],"Budget",
SUMX(FILTER(ALL('Table'),[Sector]=EARLIER('Table'[Sector])&&[Directorate]=EARLIER('Table'[Directorate])),[Estimated Budget]),
    "Level","1")
var _table2=
SUMMARIZE(
    'Table',[Directorate],'Table'[Expenditure Type],"Budget",
    SUMX(
        FILTER(ALL('Table'),
        [Directorate]=EARLIER('Table'[Directorate])&&
        [Expenditure Type]=EARLIER('Table'[Expenditure Type])),[Estimated Budget]),
        "Level","2")
return
UNION(
    _table1,_table2)

2. Result:

vyangliumsft_0-1717141377851.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thank you @Anonymous . This is what I was trying to get. 

 

In case I need a filter(Slicer) for Sector/Year, for example, if 2024 and Sector A is selected then the Sankey chart should show 2024 and Sector A data only, what will be a good approach and which table I should filter?

snehasissamal
Frequent Visitor

Thanks lbendlin, Here is the data:

 

Original Data

 

YearSectorDirectorateDescriptionExpenditure TypeEstimated Budget
2024Sector ADirectorate AA1Project 1Locked10000
2024Sector ADirectorate AA1Project 2Spent2000
2024Sector ADirectorate AA1Project 3Remaining8000
2024Sector ADirectorate AA2Project 4Locked5000
2024Sector ADirectorate AA2Project 5Remaining2000
2024Sector BDirectorate BB1Project 6Locked50000
2024Sector BDirectorate BB1Project 7Spent25000
2024Sector BDirectorate BB1Project 8Remaining25000
2024Sector BDirectorate BB2Project 9Locked100000

 

 

Required Data Format

SourceTargetBudgetLevel
Sector ADirectorate AA1200001
Sector ADirectorate AA270001
Sector BDirectorate BB11000001
Sector BDirectorate BB21000001
Directorate AA1Locked100002
Directorate AA1Spent20002
Directorate AA1Remaining80002
Directorate AA2Locked50002
Directorate AA2Remaining20002
Directorate BB1Locked500002
Directorate BB1Spent250002
Directorate BB1Remaining250002
Directorate BB2Locked1000002
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...


Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.