Combine Excel Power Query Tables and Count Items by ID
Question details
Combine two differently structured Power Query datasets and count item records for each ID.

- Product
- Microsoft Excel Power Query
- Device & OS
- not provided
- Scenario
- One dataset stores items across columns, while another contains item records in rows. The user wants a unified item-count table and PivotTable.
- Observed behavior
- The desired result is a count of item records by ID, request, and item, with IDs that have no items retained if needed.
Identify the ID and request columns in both datasets and confirm which item columns in Dataset A use Yes to indicate an item. Check whether repeated rows represent separate items that should each be counted.
Normalize, append, and group the Power Query tables
Use this method to count item records from both datasets without multiplying repeated rows in a merge.
Both queries should contain one row per item record, with matching ID, request, and item column names and compatible data types. Count Rows counts repeated records; it does not count distinct requests.
In Excel, open Data > Queries & Connections, then double-click Dataset A to open it in Power Query Editor.
Select the ID and request columns, then choose Transform > Unpivot Columns > Unpivot Other Columns. Filter the resulting Value column to Yes, rename Attribute to item, and remove Value.
Open Dataset B in Power Query Editor and rename its corresponding columns to ID, request, and item. Keep one row per item record and set compatible data types in both queries using the column data type controls.
Choose Home > Append Queries > Append Queries as New, select the two normalized queries, and confirm. Appending stacks the item records instead of joining repeated rows.
Select ID, request, and item, then choose Home > Group By. Use Advanced grouping for all three columns, name the new column Count, and select the Count Rows operation.
Choose Home > Close & Load To and select Add this data to the Data Model if available. Create a PivotTable from the loaded result, placing ID, request, and item in the desired fields and Count in Values.

Review item-count spreadsheets in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for opening and working with Excel spreadsheets. It supports common Microsoft Office formats, making it easy to move existing files into WPS. The Power Query workflow itself remains an Excel task.

Frequently Asked Questions
Why should I append the queries instead of merging them?
Home > Append Queries stacks matching columns into one list of item records. A merge on repeated keys can create multiple matched rows and inflate counts.
How do I keep an ID that has no item records?
In Power Query Editor, merge a complete ID list with the grouped counts using a left outer join. Expand the count column and replace null counts with 0.
How can I show zero counts for every item?
Create a complete list of the ID, request, and item combinations you want to display. Left-join the grouped counts to that list, expand the count column, and replace nulls with 0.
Will Count Rows remove duplicate item records?
No. Group By with Count Rows counts every row in each group. If duplicates are errors rather than separate records, remove them using Home > Remove Rows > Remove Duplicates before grouping.




