The SUMPRODUCT function
SUMPRODUCT multiplies each row of one range by the same row of another, then adds up all those products. Quantity × price for every line of an order, totalled, without a helper column.
It can also do conditional totals: multiply by a test like (D2:D5="Paper"), which is 1 for matching rows and 0 for the rest.
=SUMPRODUCT(array1, [array2], ...)
Arguments
- array1
- The first range or array, such as the quantities.
- array2, ...optional
- More ranges of the same size, such as the unit prices. Each row is multiplied across, then everything is added.
Try it
=SUMPRODUCT(B2:B5,C2:C5) in F2. 12 × £1.50 + 30 × £0.45 + 8 × £2.25 + 2 × £6.99 = £63.48.
F2
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Item | Qty | Unit price | Type | Order total | ||
| 2 | Notebooks | 12 | £1.50 | Paper | £63.48 | ||
| 3 | Pens | 30 | £0.45 | Writing | |||
| 4 | Folders | 8 | £2.25 | Paper | |||
| 5 | Stapler | 2 | £6.99 | Desk | |||
| 6 | |||||||
| 7 |
Edit the formula in F2, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =SUMPRODUCT((D2:D5="Paper")*B2:B5*C2:C5) | £36.00 | The test is 1 for Paper rows and 0 for others, so only notebooks and folders are counted. |
| =SUMPRODUCT(B2:B5) | 52 | With one range it's just a SUM: 52 items altogether. |
| =SUMPRODUCT((B2:B5>10)*1) | 2 | A count with a condition: two lines have more than 10 items. |
Tips
- All the ranges must be the same size, e.g. all rows 2 to 5.
- To use a condition, multiply it in:
(range="x")*values. The brackets matter. - SUMIFS is easier to read when you only need simple conditions; SUMPRODUCT shines when you need to multiply columns as well.
Common mistakes
- #VALUE! appears.The ranges are different sizes, often because one includes the header row. Start them all on the same row.
- A condition written as a separate argument gives 0.Excel treats TRUE/FALSE in a separate argument as 0. Multiply the test into another range instead, as in
(D2:D5="Paper")*B2:B5, or use--(D2:D5="Paper"). - Some rows are missing from the total.A quantity or price is stored as text, which SUMPRODUCT treats as 0. Convert it to a number.
Practise SUMPRODUCT with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.