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
Uldevi
Frequent Visitor

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
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! Prices go up Feb. 11th.

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.