Forum Discussion
apoje
6 years agoHelper II
Merge multiple columns into one column
I have a dataset which contains what specific items are a part of a bundle, there is also the associated quantity. Bundle has up to 4 components and I have 4 columns that carry variation.id and 4 col...
v-frfei-msft
6 years agoCommunity Support
Hi apoje ,
Did you want to union the columns? Kindly share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.
- apoje6 years agoHelper II
HI v-frfei-msft,
the example data is in the table not in the PQ. With some deleted rows. I am would like to append those 8 Columns into 2. And than preform a group by function in PQ.
Hopefully you can help.
Thank you!
Andraz
- Anonymous6 years agoNot applicable
The code below will get you to the point where you can group by. Hope it helps!
let Source = Excel.CurrentWorkbook(){[Name="stock_bundle"]}[Content], #"Replaced Value" = Table.ReplaceValue(Source,0,null,Replacer.ReplaceValue,{"var-nr-1", "product-1", "var-nr-2", "product-2", "var-nr-3", "product-3", "var-nr-4", "product-4"}), #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {}, "Attribute", "Product"), AddVar = Table.AddColumn(#"Unpivoted Other Columns", "Var", each if Text.Start([Attribute],6) = "var-nr" then [Product] else null), #"Filled Down" = Table.FillDown(AddVar,{"Var"}), #"Filtered Rows" = Table.SelectRows(#"Filled Down", each Text.StartsWith([Attribute], "product")) in #"Filtered Rows"