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
bharukc
Helper I
Helper I

Pivot multiple values of one id

I have a table that I need to pivot. Pivoting should create multiple rows per id

parent.   Child.   Level

C              A.         1

C             B.          2

A.             D.          1

C.             E.           1

end result

parent.  Level 1.     Level 2

C.            A.             B

C.            E.              Null

A.            D

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @bharukc ,

I created a sample pbix file(see the attachment), please check if that is what you want.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclbSUXLUAxKGSrE6EK4TiGsE5oJlXJCkQUxXKD8WAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"parent." = _t, #"Child." = _t, Level = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"parent.", type text}, {"Child.", type text}, {"Level", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Level", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Level", type text}}, "en-US")[Level]), "Level", "Child."),
    #"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"1", "Level 1"},{"2", "Level 2"}})
in
    #"Renamed Columns"

yingyinr_0-1666751974649.png

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @bharukc ,

I created a sample pbix file(see the attachment), please check if that is what you want.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclbSUXLUAxKGSrE6EK4TiGsE5oJlXJCkQUxXKD8WAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"parent." = _t, #"Child." = _t, Level = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"parent.", type text}, {"Child.", type text}, {"Level", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Level", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Level", type text}}, "en-US")[Level]), "Level", "Child."),
    #"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"1", "Level 1"},{"2", "Level 2"}})
in
    #"Renamed Columns"

yingyinr_0-1666751974649.png

Best Regards

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.