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
PBI_newuser
Post Prodigy
Post Prodigy

How to transform data in power query

Hi, I have an excel file as below. How to transform the data to the expected result?

CampaignNameProductAmtProductAmtProductAmt
ABP-1123P-3321P-5456
CDP-2444P-4444P-6666

 

Expected result:

CampaignNameProductAmt
ABP-1123
ABP-3321
ABP-5456
CDP-2444
CDP-4444
CDP-6666
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@PBI_newuser , Add this code in blank Query in power query and check

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXIC4gBdQyBpaGQMZoNIYyNDMNsUSJqYminF6kQrOQPZLmBRI5CoiQmYbYLENgOSZmZA1bEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Campaign = _t, Name = _t, Product = _t, Amt = _t, Product.1 = _t, Amt.1 = _t, Product.2 = _t, Amt.2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Campaign", type text}, {"Name", type text}, {"Product", type text}, {"Amt", Int64.Type}, {"Product.1", type text}, {"Amt.1", Int64.Type}, {"Product.2", type text}, {"Amt.2", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Name", "Campaign"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Attribute.1]), "Attribute.1", "Value")
in
#"Pivoted Column"

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@PBI_newuser , Add this code in blank Query in power query and check

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXIC4gBdQyBpaGQMZoNIYyNDMNsUSJqYminF6kQrOQPZLmBRI5CoiQmYbYLENgOSZmZA1bEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Campaign = _t, Name = _t, Product = _t, Amt = _t, Product.1 = _t, Amt.1 = _t, Product.2 = _t, Amt.2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Campaign", type text}, {"Name", type text}, {"Product", type text}, {"Amt", Int64.Type}, {"Product.1", type text}, {"Amt.1", Int64.Type}, {"Product.2", type text}, {"Amt.2", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Name", "Campaign"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(".", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Attribute.1]), "Attribute.1", "Value")
in
#"Pivoted Column"

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.