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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
sathar01_1
New Member

Preparing Hierarchy/Lineage data for Sankey Chart

Hi All,

 

I want to prepare the following data to suit the Sankey needs. Can you please help with the wasy way of doing it.

Original Data

Layer 1Layer 2Layer 3Layer 4Layer 5
ABCDE
AABBCCDDEE
AAABBBCCCDDDEEE

 

Expected data:

 

SourceTargetWeight
AB

1

BC1
CD1
DE1
AABB1
BBCC1
CCDD1
DDEE1
AAABBB1
BBBCCC1
CCCDDD1
DDDEEE1

 

What is the easiest way to prep the data like the one above? Thanks in advance.

2 ACCEPTED SOLUTIONS
HoangHugo
Solution Specialist
Solution Specialist

Hi, try this

 

Table = UNION(SELECTCOLUMNS(table,"Source",Layer 1 column,"Target",Layer 2 column),
                         SELECTCOLUMNS(table,"Source",Layer 2 column,"Target",Layer 3 column),

                        SELECTCOLUMNS(table,"Source",Layer 3 column,"Target",Layer 4 column),

                        SELECTCOLUMNS(table,"Source",Layer 4 column,"Target",Layer 5 column)

                    )

View solution in original post

It works great. Thanks for your response... The Exact code i used is given below.

 



Sankey = UNION(SELECTCOLUMNS(Test,"Source",[Layer 1] ,"Target",[Layer 2] ),
                         SELECTCOLUMNS(Test,"Source",[Layer 2] ,"Target",[Layer 3]),
                        SELECTCOLUMNS(Test,"Source",[Layer 3] ,"Target",[Layer 4] ),
                        SELECTCOLUMNS(Test,"Source",[Layer 4] ,"Target",[Layer 5] )
                    )
 

View solution in original post

2 REPLIES 2
HoangHugo
Solution Specialist
Solution Specialist

Hi, try this

 

Table = UNION(SELECTCOLUMNS(table,"Source",Layer 1 column,"Target",Layer 2 column),
                         SELECTCOLUMNS(table,"Source",Layer 2 column,"Target",Layer 3 column),

                        SELECTCOLUMNS(table,"Source",Layer 3 column,"Target",Layer 4 column),

                        SELECTCOLUMNS(table,"Source",Layer 4 column,"Target",Layer 5 column)

                    )

It works great. Thanks for your response... The Exact code i used is given below.

 



Sankey = UNION(SELECTCOLUMNS(Test,"Source",[Layer 1] ,"Target",[Layer 2] ),
                         SELECTCOLUMNS(Test,"Source",[Layer 2] ,"Target",[Layer 3]),
                        SELECTCOLUMNS(Test,"Source",[Layer 3] ,"Target",[Layer 4] ),
                        SELECTCOLUMNS(Test,"Source",[Layer 4] ,"Target",[Layer 5] )
                    )
 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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