Example 1
Total value: quantity times price
B7 =SUMPRODUCT(B2:B5,C2:C5)
Result: 102.00
10 x 2.50 + 4 x 8 + 6 x 5 + 12 x 1.25. No helper column is needed.
B7 =SUMPRODUCT(B2:B5,C2:C5) returns 102.00
Multiplies matching items in two or more ranges and adds the results. Also counts and sums with calculated conditions.
Syntax
=SUMPRODUCT(, [array2], …)
All versions of Excel.
Try it
Edit the formula in B7 or change the inputs. The sheet recalculates as you type.
B7 =SUMPRODUCT(B2:B5,C2:C5) returns 102.00
SUMPRODUCT multiplies the items in two or more ranges that sit in the same position, then adds up the products. Its first job is the one in the name: quantity times price, summed. Its second job is as an all-purpose conditional sum and count that works without helper columns.
With quantities in B2:B6 and prices in C2:C6, =SUMPRODUCT(B2:B6, C2:C6) returns the total value. It is the same as multiplying each row and then using SUM, without the extra column. The ranges must be the same size. If one has an extra row, the result is #VALUE!.
Comparing a range to a value produces an array of TRUE and FALSE. Multiplying by it turns TRUE into 1 and FALSE into 0, so only the matching rows count:
=SUMPRODUCT((A2:A6="North") * B2:B6 * C2:C6)
Join conditions with * for AND and + for OR. To count rows instead of summing, leave out the numbers: =SUMPRODUCT((A2:A6="South") * (B2:B6>15)).
You can also pass a condition as its own argument. Convert it with a double minus first, as in SUMPRODUCT(--(A2:A6="North"), B2:B6, C2:C6), because a bare TRUE/FALSE array counts as zero.
Divide by the total weight to get a weighted average: =SUMPRODUCT(B2:B4, C2:C4) / SUM(C2:C4). AVERAGE can't do this because it gives every value equal weight.
* with a text cell in the range returns #VALUE!. Passing the ranges as separate arguments, as in SUMPRODUCT(B2:B6, C2:C6), treats text as zero instead.Calculations over thousands of rows with several arrays can be slow, because every array is rebuilt on each recalculation.
B2:B9, or a calculated array such as (A2:A9="North")*B2:B9.#VALUE!. Cells that hold text are treated as 0 when arrays are passed as separate arguments.Each example is a live sheet. Change the inputs or the formula and watch the result.
Example 1
B7 =SUMPRODUCT(B2:B5,C2:C5)
Result: 102.00
10 x 2.50 + 4 x 8 + 6 x 5 + 12 x 1.25. No helper column is needed.
B7 =SUMPRODUCT(B2:B5,C2:C5) returns 102.00
Example 2
B8 =SUMPRODUCT((A2:A6="North")*B2:B6*C2:C6)
Result: 90
The test A2:A6="North" gives 1 for North rows and 0 for the rest, so only 10 x 5 and 5 x 8 survive.
B8 =SUMPRODUCT((A2:A6="North")*B2:B6*C2:C6) returns 90
Example 3
B8 =SUMPRODUCT(((A2:A6="North")+(A2:A6="East"))*B2:B6*C2:C6)
Result: 138
Adding the two tests gives 1 for either region. North is 90 and East is 48.
B8 =SUMPRODUCT(((A2:A6="North")+(A2:A6="East"))*B2:B6*C2:C6) returns 138
Example 4
B8 =SUMPRODUCT((A2:A6="South")*(B2:B6>15))
Result: 1
Only the second row is South with more than 15 units. Multiplying two tests gives AND.
B8 =SUMPRODUCT((A2:A6="South")*(B2:B6>15)) returns 1
Example 5
B6 =SUMPRODUCT(B2:B4,C2:C4)/SUM(C2:C4)
Result: 78
The score times the weight, summed, is 16 + 27 + 35 = 78. Dividing by the total weight keeps the result right even if the weights don't add to 1.
B6 =SUMPRODUCT(B2:B4,C2:C4)/SUM(C2:C4) returns 78
Solve it in the sheet. Every answer is checked, with hints if you need them.
Task 1 of 2
In B9, return the total cost of all items: quantity times unit cost, added up.
Answer in B9.
B2:B6 and C2:C5, SUMPRODUCT returns #VALUE!. Make every array the same shape.* over a range that contains text returns #VALUE!. Passing the ranges as separate arguments treats the text as 0 instead, which can hide a data problem.SUMPRODUCT((A2:A6="North"), B2:B6), is treated as 0 because TRUE/FALSE isn't a number. Use --(A2:A6="North") or multiply it in.It multiplies the first item of each range together, then the second, and so on, and adds up all the products. It is quantity times price, summed, in one step.
Multiply the condition into the arrays: `=SUMPRODUCT((A2:A9="North")*B2:B9)` adds column B where column A says North. Use `*` for AND and `+` for OR.
The arrays are different sizes, or you multiplied a range that holds text. Check that every range has the same rows and columns, and look for text in numeric columns.
Not for simple tests: SUMIFS is easier to read and faster. SUMPRODUCT wins when the condition is calculated, such as `MONTH(A2:A9)=3`, or case-sensitive.
It turns TRUE and FALSE into 1 and 0. In `SUMPRODUCT(--(A2:A9="North"), B2:B9)` the first argument would otherwise be ignored as non-numeric.
SUMPRODUCT is taught in Logic and text, lesson 18: VALUE and text numbers. Each lesson is a short, graded exercise like the one above.