Forum Discussion
siva3012
9 years agoHelper II
Convert columns data into columns title
I need to convert the data in the left side table as shown in the dig into right side table. How it can be converted ?
- 9 years ago
Hi,
you can actually do this with pivot option in the power query. please see below. Code also attached!
let Source = Excel.Workbook(File.Contents("C:\Users\Dilumd\OneDrive - \help file.xlsx"), null, true), Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data], #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Time", type time}, {"Price", Int64.Type}, {"Description", type text}}), #"Reordered Columns" = Table.ReorderColumns(#"Changed Type",{"Date", "Time", "Description", "Price"}), #"Pivoted Column" = Table.Pivot(#"Reordered Columns", List.Distinct(#"Reordered Columns"[Description]), "Description", "Price") in #"Pivoted Column"
dilumd
9 years agoImpactful Individual
Hi,
you can actually do this with pivot option in the power query. please see below. Code also attached!
let
Source = Excel.Workbook(File.Contents("C:\Users\Dilumd\OneDrive - \help file.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Time", type time}, {"Price", Int64.Type}, {"Description", type text}}),
#"Reordered Columns" = Table.ReorderColumns(#"Changed Type",{"Date", "Time", "Description", "Price"}),
#"Pivoted Column" = Table.Pivot(#"Reordered Columns", List.Distinct(#"Reordered Columns"[Description]), "Description", "Price")
in
#"Pivoted Column"Greg_Deckler
9 years agoCommunity Champion
That works like a champ!