Power Query Problems

Expand a Bill of Materials into Order Components with Excel Power Query

Kushani NimanthikaKushani Nimanthika Dec 2, 2026 868 views

Question details

Expand ordered kits or parent products into their bill-of-materials components while accounting for the ordered quantity.

Expand a Bill of Materials into Order Components with Excel Power Query
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
An order table contains both kits and standalone products, and a separate bill-of-materials table lists each kit's components and quantities.
Observed behavior
The desired output contains one row per required component for each order, with component quantities multiplied by the ordered quantity and standalone products retained.
Before you start

Prepare an order table with Product and OrderQty columns and a BOM table with Parent, Component, and ComponentQty columns. Make sure product identifiers match between the tables, component identifiers are not blank, and quantity columns use numeric data types.

Solution 1Recommended

Merge the order and BOM tables in Power Query

Use a left outer merge to expand matching kits and keep standalone products in the same output.

This example expands one BOM level. If a component is itself a kit, repeat the expansion for additional levels or use a recursive approach.

The formulas below assume the column names shown in the preparation step and that the expanded BOM columns retain their prefix.

1
Load both tables

Select each source table in Excel and choose Data > From Table/Range. In Power Query, set the identifier columns to matching data types and the quantity columns to numeric types, then use Home > Close & Load To to create connections.

2
Merge the queries

In Data > Queries & Connections, right-click the orders query and select Edit. Choose Home > Merge Queries, select the BOM query, match Product to Parent, and choose Left Outer as the join kind.

3
Expand the BOM columns

Select the expand icon in the merged BOM column. Choose Component and ComponentQty, keep the option to use the original column name as a prefix, and select OK. Each matching BOM component becomes a separate order row.

4
Choose the output product

Select Add Column > Custom Column and name it OutputProduct. Enter: if [BOM.Component] = null then [Product] else [BOM.Component]. Replace BOM in the formula if your merged column has a different name.

5
Calculate the required quantity

Select Add Column > Custom Column and name it RequiredQty. Enter: if [BOM.Component] = null then [OrderQty] else [OrderQty] * [BOM.ComponentQty]. Set RequiredQty to an appropriate numeric type.

6
Load the expanded list

Use Home > Choose Columns to retain the order identifiers, OutputProduct, and RequiredQty, along with any other needed fields. Select Home > Close & Load to return the expanded list to Excel.

Merge the order and BOM tables in Power Query
Check unmatched products: Any product without a BOM match is treated as standalone. Review unmatched rows to distinguish genuine standalone products from misspelled or missing kit identifiers.
Free Microsoft Office alternative

Work with order and BOM spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for reviewing order and component lists. Its Microsoft Office format compatibility helps you move existing files between applications; it does not replace Excel Power Query for the merge described above.

Review and edit order and bill-of-materials tables in WPS SpreadsheetsOpen and save Microsoft Excel formats such as XLSXUse a familiar spreadsheet interface for easier migrationWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

How is the required component quantity calculated?

For a matched kit, multiply OrderQty by BOM.ComponentQty in an Add Column > Custom Column formula. For example, three ordered kits requiring two units of a component each produce a required quantity of six.

How do I keep products that are not kits?

Choose Left Outer when merging the orders and BOM queries. The custom columns can then retain Product and OrderQty when BOM.Component is null.

Why is a kit being treated as a standalone product?

Its Product value may not match a Parent value in the BOM table. Check spelling, spaces, identifier data types, and whether the kit exists in the BOM before refreshing the query.

Can this method expand components that are also kits?

The merge described here expands one BOM level. For nested kits, repeat the expansion for further levels or use a recursive Power Query approach.

How do I update the expanded list after changing the source tables?

Update the order or BOM table in Excel, then select Data > Refresh All to rerun the queries and update the loaded results.