Function Problems

How to Sum Quantities by Size, Length, and Code in Excel

Jason MillerJason Miller Oct 20, 2026 873 views

Question details

The user needs to calculate the total quantities for rows that share the exact same size, length, and code combinations from a dataset.

How to Sum Quantities by Size, Length, and Code in Excel
Product
Microsoft Excel 365
Device & OS
not provided
Scenario
Consolidating duplicate records into a unique list of items while summing up their corresponding quantities based on multiple matching criteria.
Observed behavior
A consolidated list of unique size, length, and code combinations is generated alongside their dynamically calculated total quantities.
Before you start

Ensure your data has clear column headers and no merged cells. If you plan to use the UNIQUE function, verify that you are using Excel 365, Excel 2021, or WPS Office, as older versions do not support dynamic arrays.

Solution 1Recommended

Use UNIQUE and SUMIFS Functions

Extract a unique list of attributes and conditionally sum their quantities using a combination of dynamic arrays and SUMIFS.

This formula approach is highly scalable as more data is added. It uses the UNIQUE function to spill the distinct combinations automatically, followed by SUMIFS to look up and calculate the totals for those matching rows.

1
Generate unique combinations

Assuming your Size, Length, and Code data are in columns B, C, and D (rows 2 to 440). Select an empty cell, for example, G2, and enter the formula: =UNIQUE($B$2:$D$440). Press Enter to spill the unique list.

2
Set up the SUMIFS formula

Assuming your Quantity is in column A. In cell J2 (beside the first unique combination), type the formula: =SUMIFS($A$2:$A$440,$B$2:$B$440,G2,$C$2:$C$440,H2,$D$2:$D$440,I2).

3
Apply formula to all rows

Format the formula cell as General. Click the fill handle in the bottom right corner of cell J2 and drag it down to fill the formula alongside all spilled unique combinations.

Use UNIQUE and SUMIFS Functions
Formula Formatting Tip: Ensure the formula cell is formatted as General. Do not preselect the spill range; just press Enter normally. The UNIQUE formula will spill automatically in supported spreadsheet versions.
Advanced Spreadsheet Solution

Sum Data by Multiple Criteria Effortlessly in WPS Office

WPS Spreadsheet fully supports dynamic array functions like UNIQUE and standard functions like SUMIFS, making it easy to summarize large datasets. It also provides a robust PivotTable interface for codeless data consolidation.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open the file containing your quantity and criteria data.
  2. 2. Apply the UNIQUE function: Type =UNIQUE(B2:D440) in a blank cell to instantly generate your unique combinations of size, length, and code.
  3. 3. Calculate totals with SUMIFS: Use the =SUMIFS() function alongside your spilled array to calculate the total quantities based on the unique criteria.
  4. 4. Alternative: Use PivotTables: Navigate to the Insert tab and click PivotTable to group and sum your multi-criteria data in just a few clicks.
Fully compatible with Microsoft Excel formulas and .xlsx file formatsNative support for UNIQUE, SUMIFS, and dynamic array spillingAdvanced PivotTable features for quick data consolidationFree to download and lightweight for Windows, Mac, and Linux
microsoft office alternative - wps office

Frequently Asked Questions

Why am I getting a #SPILL! error when using the UNIQUE function?

The #SPILL! error occurs when the dynamic array formula does not have enough blank cells to display all the results. Clear the cells below and to the right of the formula cell to allow the data to spill automatically.

Can I use the UNIQUE function in older versions of Excel?

No, the UNIQUE function is only available in Excel 365, Excel 2021, and modern spreadsheet tools like WPS Office. For older versions, you must use the Advanced Filter feature or create a PivotTable to extract unique values.

How do I automatically include new rows in my SUMIFS calculation?

Convert your source data into a Table by selecting the data and pressing Ctrl+T. Then, update your UNIQUE and SUMIFS formulas to reference the Table columns (e.g., Table1[Size]) instead of fixed ranges like $B$2:$D$440.