Google Sheets function · Array
SUMPRODUCT in Google Sheets: syntax and examples
SUMPRODUCT multiplies the entries that share a position in two or more ranges and adds the products. With tests inside the arguments it also works as a SUMIFS or COUNTIFS that accepts OR logic.
Syntax
SUMPRODUCT(array1, [array2, ...])
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
array1 | range | yes | The first range or array. With one array the function just adds it up. |
array2, ... | range | no | More ranges of exactly the same size. Entries in the same position are multiplied. |
Examples
The examples use this table, starting in A1:
| Region | Product | Units | Price |
| North | Pen | 10 | 2.5 |
| South | Pen | 4 | 2.5 |
| North | Book | 3 | 12 |
| East | Book | 8 | 12 |
| South | Lamp | 5 | 30 |
=SUMPRODUCT(C2:C6, D2:D6)Result: 317
Total value: units times price on each row, then summed.
Run in a Google Sheet (English US locale) on .
=SUMPRODUCT((A2:A6="North") * C2:C6 * D2:D6)Result: 61
One condition: the test gives TRUE or FALSE per row, and multiplying turns it into 1 or 0.
Run in a Google Sheet (English US locale) on .
=SUMPRODUCT(--(C2:C6>4))Result: 3
Counting rows that meet a test: the double minus converts TRUE and FALSE to 1 and 0.
Run in a Google Sheet (English US locale) on .
=SUMPRODUCT(((A2:A6="North") + (A2:A6="East")) * C2:C6 * D2:D6)Result: 157
OR logic: a plus between two tests means either region counts.
Run in a Google Sheet (English US locale) on .
=SUMPRODUCT(C2:C6)Result: 30
With one argument it is a plain sum.
Run in a Google Sheet (English US locale) on .
Common errors
- Every range must have the same size. C2:C6 with D2:D5 returns #VALUE!.
- Text in a range counts as zero when the ranges are separated by commas. SUMPRODUCT(A2:A6, C2:C6) returns 0 because column A has words.
- Sheets reads a test given as its own argument as 1 and 0, so SUMPRODUCT(A2:A6="North", C2:C6) returns 13. Excel returns 0 for the same formula, so multiply the parts with * when the file must work in both.
Compared with Excel
Same syntax in Excel, with one difference: a test passed as a separate argument counts as 1 and 0 in Sheets but as zero in Excel. Multiplying the tests with * works in both.