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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Uldevi
Helper I
Helper I

How to create both from and to in same column to use hierarchy in power bi using matrix visual

Hi,

How can I add the "From" and "To" column for the hierarchy as shown in the image? Could you please help me with this? 

I want to count the number of people who transferred from one location to another, grouped by region and location.

1000021192.jpg

 thanks,

 

 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Uldevi 

You need to first UnPivot the lat two columns (From and To) then use a simple measure to Count the ROWS: file attached.

Fowmy_0-1738002447900.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sxLyUxU0lHySszTNTIBMooS87IySzKALJfUnIxMIO2UnlOkFKuDUOuWmqRrZIqiFqxGR8m3NDcpMRNFsW9ipa6RGYriXIgqHaXs/OzEkkQ05UUQd5RlFiVm4XNFcGqBrpE5kkrcbvBPLtE1tERSiuGCWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [country = _t, date = _t, name = _t, #"transferred from" = _t, #"transferred to" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"country", type text}, {"date", type date}, {"name", type text}, {"transferred from", type text}, {"transferred to", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"country", "date", "name"}, "FromTo", "Location")
in
    #"Unpivoted Other Columns"




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

1 REPLY 1
Fowmy
Super User
Super User

@Uldevi 

You need to first UnPivot the lat two columns (From and To) then use a simple measure to Count the ROWS: file attached.

Fowmy_0-1738002447900.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sxLyUxU0lHySszTNTIBMooS87IySzKALJfUnIxMIO2UnlOkFKuDUOuWmqRrZIqiFqxGR8m3NDcpMRNFsW9ipa6RGYriXIgqHaXs/OzEkkQ05UUQd5RlFiVm4XNFcGqBrpE5kkrcbvBPLtE1tERSiuGCWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [country = _t, date = _t, name = _t, #"transferred from" = _t, #"transferred to" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"country", type text}, {"date", type date}, {"name", type text}, {"transferred from", type text}, {"transferred to", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"country", "date", "name"}, "FromTo", "Location")
in
    #"Unpivoted Other Columns"




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors