Forum Discussion
smk1
2 years agoRegular Visitor
Unpivot Large file having multiple groups into single group using power query
I have a large file having data by concatenating multiple files, each file is saperated by a group. I want to remove that group and make it part of header of data.
- 2 years ago
Done. Here is the query:
let Source = Csv.Document(File.Contents("your filename here.csv"),[Delimiter=",", Columns=11, QuoteStyle=QuoteStyle.None]), #"Added Custom" = Table.AddColumn(Source, "Custom", each if [Column1] = "Plant" then [Column2] else null), #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}), #"Filtered Rows" = Table.SelectRows(#"Filled Down", each [Column1] <> "Plant"), #"Promoted Headers" = Table.PromoteHeaders(#"Filtered Rows", [PromoteAllScalars=true]), #"Filtered Rows1" = Table.SelectRows(#"Promoted Headers", each [textbox11] <> "textbox11"), #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows1",{{"1001", "Plant"}}), #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Plant", "textbox11", "textbox1", "OwnerID", "textbox4", "Receipt_Total", "BOL_Total", "Issue_Total", "Transfer_Total", "Regrade_Total", "Adjustment_Total", "textbox8"}) in #"Reordered Columns"You have to plg in the filename and I kept every column as text because of possibly different setting for decimal separators, but I am sure you can make the last tweaks yourself...
PwerQueryKees
2 years agoSuper User
Doable, if you send a file with (test) data I'll give it a go....