Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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)?
in the example the var-nr represents variation id, and product represents the stock quantity.
Thank you!
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.
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
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"
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
6 | |
6 | |
6 | |
6 |
User | Count |
---|---|
9 | |
9 | |
8 | |
6 | |
6 |