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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
apoje
Helper II
Helper 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 columns that carry stock of that specific variation. Basically 8 columns in total. I would like to combine those 8 columns into 2 columns where I could than preform a group by function – to get out the unique SKUs and their respective quantity.

 

How could I combine those 8 columns into only 2 (variation.id and stock)?

 

forum_PQ.jpg

 in the example the var-nr represents variation id, and product represents the stock quantity.

 

Thank you!

3 REPLIES 3
v-frfei-msft
Community Support
Community 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.

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

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. 

 

https://ipotechnik-my.sharepoint.com/:x:/g/personal/andraz_poje_ipotechnik_de/ES51pnTEvUJMht_Vq7niJH...

 

Thank you!

Andraz

Anonymous
Not 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"

  

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors