Use SUMPRODUCT to multiply pairs and add the results
SUMPRODUCT multiplies matching items in two or more arrays, then adds up the products. The syntax is:
=SUMPRODUCT(array1, [array2], ...)
The arrays must be the same size and shape. SUMPRODUCT works in every version of Excel without needing Ctrl+Shift+Enter.
Quantity times price
Here is a small order list:
| Item | Quantity | Price |
|---|---|---|
| Pens | 4 | 2.50 |
| Notebooks | 3 | 4.00 |
| Folders | 10 | 0.75 |
To find the order total, multiply each quantity by its price and add the results:
=SUMPRODUCT(B2:B4, C2:C4)
That’s 4 × 2.50, plus 3 × 4.00, plus 10 × 0.75, which comes to 10 + 12 + 7.50 = 29.50.
Conditional totals
To total values only for the rows that match a condition, turn the test into a 1 or a 0 and let the multiplication do the filtering. Here is a sample of revenue by type:
| A (Type) | B (Revenue) |
|---|---|
| Office | 120 |
| Kitchen | 80 |
| Office | 45 |
| Office | 200 |
=SUMPRODUCT(--(A2:A5="Office"), B2:B5)
This returns 365. The double minus sign (–) turns TRUE into 1 and FALSE into 0, so only the Office rows contribute.
The same test can be written without the double minus: =SUMPRODUCT((A2:A5="Office")*B2:B5). That form breaks when a value in column B is text. The comma form treats text as zero, which makes it the safer choice when the data isn’t clean.
Count rows that match two conditions
SUMPRODUCT can count as well as add. This counts the Office rows with revenue above 100:
=SUMPRODUCT((A2:A5="Office")*(B2:B5>100))
The result is 2, for the Office rows worth 120 and 200. Each test returns TRUE or FALSE, and multiplying them makes a row count only when both are true.
Weighted average
To get an average price per unit, weighted by quantity, divide the order total by the number of units:
=SUMPRODUCT(B2:B4, C2:C4) / SUM(B2:B4)
For the order list, that’s 29.50 divided by 17 units, or about 1.74 per unit.
Common problems
- #VALUE! appears when the arrays are different sizes, so check that the ranges have the same number of rows.
- #VALUE! from the multiplication form appears when a cell in a multiplied range contains text. Switch to the comma form, or clean the data.
- A total that looks too small can mean a number is stored as text and the comma form is treating it as zero. How to convert text to number in excel covers the fix.
When SUMIFS is simpler
For plain conditions, SUMIFS is easier to read, and the approach in sumifs with multiple criteria in excel avoids the double minus sign altogether. SUMPRODUCT is most useful when you need to multiply columns first, as in the quantity-times-price case.