Power Query Problems

How to Group Items and Sum Quantities with Power Query

Aamir Naveed AkramAamir Naveed Akram Nov 10, 2026 869 views

Question details

The user needs to combine duplicate item entries in a dataset and calculate the total sum of their quantities using Power Query.

How to Group Items and Sum Quantities with Power Query
Product
Excel
Device & OS
not provided
Scenario
Cleaning and summarizing a dataset where the same item appears multiple times with varying quantities, requiring a consolidated view with total amounts.
Observed behavior
The dataset currently lists multiple rows for the same item. The goal is to generate a clean table where each unique item is listed only once with its corresponding total quantity.
Before you start

Ensure your raw data is formatted as an Excel Table (Ctrl+T) before importing it into Power Query. This ensures that any future rows added to your dataset will be automatically included when you refresh the query.

Solution 1Recommended

Use the Group By Feature in Power Query

The most direct way to consolidate duplicate items and sum their quantities is to use the built-in 'Group By' function within the Power Query Editor.

The Group By function works similarly to a Pivot Table, allowing you to aggregate data based on unique values in a specific column. By selecting 'Sum' as the operation, Power Query handles the math and deduplication simultaneously.

1
Load data into Power Query

Select any cell inside your data table, navigate to the 'Data' tab on the Excel ribbon, and click 'From Table/Range' to open the Power Query Editor.

2
Access the Group By menu

In the Power Query Editor, locate the 'Item' column (or the column containing your duplicate names). Right-click the column header and select 'Group By' from the context menu.

3
Configure the Group By settings

In the Group By dialog box, under 'New column name', type a title for your results (e.g., 'Total Quantity'). Under 'Operation', click the drop-down menu and select 'Sum'.

4
Select the column to sum

Under the 'Column' drop-down, choose the 'Quantity' column (the column containing the numbers you want to add together). Click 'OK' to apply the changes.

5
Load the results back to Excel

Review the newly summarized data in the preview window. If it looks correct, click 'Close & Load' in the top-left corner of the Home tab to output the summarized table into a new worksheet.

Use the Group By Feature in Power Query
Pro Tip: If you need to update the totals later when new data is added to your original table, simply right-click anywhere in the output table and select 'Refresh'.
Free Microsoft Office alternative

Easily Summarize Data with WPS Office

While Power Query is a powerful tool in Microsoft Excel, WPS Spreadsheet offers highly intuitive Pivot Tables and Data Consolidation features that allow you to group items and sum quantities in seconds—without needing to navigate complex query editors. Try WPS Office as a free, lightweight alternative for all your data analysis tasks.

Free and lightweight alternative to Microsoft ExcelFully compatible with Microsoft Excel formats (.xlsx, .xls, .csv)Quickly group and sum data using powerful built-in Pivot TablesFamiliar user interface ensuring a seamless transition and zero learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Can I group by multiple columns at the same time in Power Query?

Yes. When you open the Group By dialog box, select the 'Advanced' option at the top instead of 'Basic'. This allows you to click 'Add grouping' to group by multiple criteria (such as Item and Date) before applying the sum operation.

Why is the Sum operation resulting in an error or grayed out?

The Sum operation requires numerical data. If your Quantity column is currently formatted as Text, Power Query cannot calculate a sum. You must change the data type by clicking the icon next to the 'Quantity' column header and selecting 'Whole Number' or 'Decimal Number' before grouping.

Is there a way to keep the other columns when grouping?

By default, grouping removes columns that aren't part of the grouping or aggregation. To keep other data, you must use the 'Advanced' Group By settings to either add those columns to the grouping criteria or add 'All Rows' as an aggregation operation to extract additional details later.