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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SonaSinghA
Helper III
Helper III

Pivot in Power Query

Hi Experts,

How can we achieve below pivoting in Power Query or close to this?

Please help?

 

UserCategoryTemplate IDTitleDocument ID  
1AX10AA94237  
1AX10AB94237  
1AX10AC94237  
2AX10AA94000  
Output      
       
UserCategoryTemplate IDTitle1Title2Title3Document ID
1AX10AAABAC94237
2AX10AA  94200
1 ACCEPTED SOLUTION
grandtotal
Resolver III
Resolver III

Try this one, copy to Advanced editor:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXKMABKGBiCWI5CwNDEyNleK1cGQdMIn6YwiaYTNWAMDA6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, Category = _t, #"Template ID" = _t, Title = _t, #"Document ID" = _t]),
#"Duplicated Column1" = Table.DuplicateColumn(Source, "Title", "Title - Copy"),
#"Pivoted Column" = Table.Pivot(#"Duplicated Column1", List.Distinct(#"Duplicated Column1"[Title]), "Title", "Title - Copy")
in
#"Pivoted Column"

 

The trick is to duplicate Title column and then Pivot:

grandtotal_1-1670850130591.png

 

Result:

grandtotal_0-1670849916990.png

 

I hope this will help you.

View solution in original post

1 REPLY 1
grandtotal
Resolver III
Resolver III

Try this one, copy to Advanced editor:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXKMABKGBiCWI5CwNDEyNleK1cGQdMIn6YwiaYTNWAMDA6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, Category = _t, #"Template ID" = _t, Title = _t, #"Document ID" = _t]),
#"Duplicated Column1" = Table.DuplicateColumn(Source, "Title", "Title - Copy"),
#"Pivoted Column" = Table.Pivot(#"Duplicated Column1", List.Distinct(#"Duplicated Column1"[Title]), "Title", "Title - Copy")
in
#"Pivoted Column"

 

The trick is to duplicate Title column and then Pivot:

grandtotal_1-1670850130591.png

 

Result:

grandtotal_0-1670849916990.png

 

I hope this will help you.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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