Skip to content

SUMPRODUCT

Multiplies matching items in two or more ranges and adds the results. Also counts and sums with calculated conditions.

Syntax

=SUMPRODUCT(, [array2], …)

Math and trigonometry

All versions of Excel.

Try it

Edit the formula in B7 or change the inputs. The sheet recalculates as you type.

B7
A
B
C
1
Item
Qty
Price
2
Pallet wrap
10
2.50
3
Gloves
4
8.00
4
Labels
6
5.00
5
Tape
12
1.25
6
7
Total value
102.00

B7 =SUMPRODUCT(B2:B5,C2:C5) returns 102.00

How SUMPRODUCT works

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.

Quantity times price

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!.

Conditions as arrays

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.

Weighted averages

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.

When to use SUMPRODUCT, and when not to

  • Use SUMIFS when the conditions test cell values directly. It is easier to read and faster on large tables.
  • Use SUMPRODUCT when a condition is calculated, for example the month of a date, a case-sensitive match with EXACT, or a comparison between two columns.
  • Using * 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.

Arguments

array1
The first range or array, such as B2:B9, or a calculated array such as (A2:A9="North")*B2:B9.
array2, …optional
More ranges or arrays, up to 255. All must have the same number of rows and columns as array1, or SUMPRODUCT returns #VALUE!. Cells that hold text are treated as 0 when arrays are passed as separate arguments.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

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
A
B
C
1
Item
Qty
Price
2
Pallet wrap
10
2.50
3
Gloves
4
8.00
4
Labels
6
5.00
5
Tape
12
1.25
6
7
Total value
102.00

B7 =SUMPRODUCT(B2:B5,C2:C5) returns 102.00

Example 2

A conditional sum: revenue for one region

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
A
B
C
D
1
Region
Units
Price
2
North
10
5
3
South
20
4
4
North
5
8
5
East
8
6
6
South
12
4.5
7
8
North revenue
90

B8 =SUMPRODUCT((A2:A6="North")*B2:B6*C2:C6) returns 90

Example 3

OR: two regions together

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
A
B
C
D
1
Region
Units
Price
2
North
10
5
3
South
20
4
4
North
5
8
5
East
8
6
6
South
12
4.5
7
8
North or East
138

B8 =SUMPRODUCT(((A2:A6="North")+(A2:A6="East"))*B2:B6*C2:C6) returns 138

Example 4

Count rows that meet two conditions

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
A
B
C
D
1
Region
Units
Price
2
North
10
5
3
South
20
4
4
North
5
8
5
East
8
6
6
South
12
4.5
7
8
South, over 15 units
1

B8 =SUMPRODUCT((A2:A6="South")*(B2:B6>15)) returns 1

Example 5

Weighted average

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
A
B
C
1
Component
Score
Weight
2
Exam
80
0.2
3
Project
90
0.3
4
Practical
70
0.5
5
6
Final mark
78

B6 =SUMPRODUCT(B2:B4,C2:C4)/SUM(C2:C4) returns 78

Your turn.

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.

B9
A
B
C
D
1
Item
Dept
Qty
Unit cost
2
Cables
IT
20
3.50
3
Mouse
IT
10
12.00
4
Paper
Admin
40
2.20
5
Toner
Admin
6
45.00
6
Chairs
Ops
4
85.00
7
Gloves
Ops
50
1.40
8
9
Total cost
10
Admin cost

Common mistakes

  • If the arrays have different sizes, such as B2:B6 and C2:C5, SUMPRODUCT returns #VALUE!. Make every array the same shape.
  • Multiplying with * 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.
  • A condition passed as its own argument, such as 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.
  • Ranges of several thousand rows with many conditions slow the workbook down. Prefer SUMIFS for simple tests.
  • SUMPRODUCT can't use whole-column references well. A:A has over a million rows, so keep the ranges to the data.

Questions people ask

What does SUMPRODUCT do in simple terms?

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.

How do I use SUMPRODUCT with a condition?

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.

Why does SUMPRODUCT return #VALUE!?

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.

Is SUMPRODUCT better than SUMIFS?

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.

What does the double minus in SUMPRODUCT do?

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.

Learn SUMPRODUCT in a real sheet.

SUMPRODUCT is taught in Logic and text, lesson 18: VALUE and text numbers. Each lesson is a short, graded exercise like the one above.