How to use the SUMPRODUCT function
The SUMPRODUCT function calculates the product of corresponding values and then returns the sum of each multiplication.
The picture above shows how the SUMPRODUCT works in greater detail.
Formula in cell B7:
The SUMPRODUCT function multiplies cell ranges row by row and then adds the numbers and returns a total. The formula in cell B7 multiples values 1*4= 4, 2*5 = 10 and 3*6 =18 and then adds the numbers 4+10+18 equals 32.
Excel Function Syntax
SUMPRODUCT(array1, [array2], ...)
Arguments
array1 | Required. Required. The first array argument whose numbers you want to multiply and then sum. |
[array2] | Optional. Up to 254 additional arguments. |
Comments
The SUMPRODUCT function is one of the most powerful functions in Excel and is one that I often use. I highly recommend learning how it works.
The SUMPRODUCT function requires you to enter it as a regular formula, not an array formula. However, there are exceptions. If you use a logical expression you must enter the formula as an array formula and convert the boolean values to their equivalents.
There are workarounds to this problem which I will demonstrate in the examples below.
Example 1 - The basics
This example demonstrates how the SUMPRODUCT function works.
Formula in cell B7:
Step 1 - Multiplying values on the same row
The first array is in cell range B2:B4 and the second array is in cell range C2:C4.
B2:B4*C2:C4
becomes
{1;2;3} * {4;5;6}
becomes
{1*4; 2*5; 3*6}
and returns {4; 10; 18}.
The same calculations are done in column D and shown in column E, see above picture.
Step 2 - Return the sum of those products
{4; 10; 18}
becomes
4 + 10 + 18
and the function returns 32 in cell B7.
The same calculation is done E5, the sum of the products in cell range E2:E4 is calculated in cell E5. See the above picture.
Now you know the basics. Let's move on to something more interesting.
Example 2 - Use a logical expression
The image above demonstrates a formula in cell G4 that counts how many cells that is equal to the value in cell G2. Note, that this is only an example. I recommend you use the COUNTIF function to count cells based on a condition, it is designed to do that.
Formula in cell G4:
Step 1 - Logical expression returns a boolean value that we must convert to numbers
There is only one array in this formula but something else is distorting the picture. A comparison operator (equal sign) and a second cell value (G2) or a comparison value. With these we have now built a logical expression. This means that the value in cell G2 is compared to all the values in cell range B2:B6 (not case sensitive).
B2:B6=$G$2
becomes
{"Alaska";"California";"Arizona";"California";"Colorado"}="California"
and returns
{FALSE; TRUE; FALSE; TRUE; FALSE}.
They are all boolean values and excel can´t sum these values. We have to convert the values to numerical values. There are a few options, you can:
- Add a zero - (B2:B6=$G$2)+0
- Multiply with 1 - (B2:B6=$G$2)*1
- Double negative signs --(B2:B6=$G$2)
They all convert boolean values to their numerical equivalents. TRUE is 1 and FALSE is 0 (zero).
--( {FALSE;TRUE;FALSE;TRUE;FALSE})
becomes
{0;1;0;1;0}
Step 2 - Return the sum of those products
{0;1;0;1;0}
becomes
0 + 1 + 0 + 1 + 0
and returns 2 in cell G4. There are two cells containing the value "California" in cell range B2:B6.
You accomplish the same thing using the COUNTIF function or count multiple values in different columns using the COUNTIFS function. In fact, you can count entire records in a data set using the COUNTIFS function.
Example 3 - Use multiple conditions in the SUMPRODUCT function
This example shows how to use multiple conditions in the SUMPRODUCT function using AND logic. AND logic means that all conditions must be met on a given row in order to add the number to the total.
Formula in cell D10:
This formula contains three arguments, the SUMPRODUCT function allows you to use up to 30 arguments. You can make the formula somewhat shorter:
This also allows you to have a lot more conditions than 30 if you like and use OR logic if you want. Example 4 demonstrates OR logic.
It is only the available computer memory that is the limit if you use this method. The formula looks like an array formula but no, you are not required to enter it as an array formula.
Step 1 - Multiplying corresponding components in the given arrays
The first logical expression B2:B8=B10 uses an equal sign to check if the values in cell range B2:B8 are equal to the value in cell B10.
B2:B8=B10
becomes
{"Alaska";"California";"Arizona";"California";"Colorado";"California";"Nevada"}="California"
and returns
{FALSE; TRUE; FALSE; TRUE; FALSE; TRUE; FALSE}.
The second logical expression is C2:C8=C10, the other logical operators you can use are:
- = equal
- < less than
- > greater than
- <> not equal to
- <= less than or equal to
- >= larger than or equal to
C2:C8=C10
becomes
{"Anchorage";"San Diego";"Phoenix";"Los Angeles";"Denver";"Los Angeles";"Las Vegas"}="Los Angeles"
and returns
{FALSE; FALSE; FALSE; TRUE; FALSE; TRUE; FALSE}.
The third and last logical
(B2:B8=B10)*(C2:C8=C10)*D2:D8
becomes
({FALSE; TRUE; FALSE; TRUE; FALSE; TRUE; FALSE})*({FALSE; FALSE; FALSE; TRUE; FALSE; TRUE; FALSE})*{10; 20; 40; 10; 20; 30; 10}
becomes
{0;0;0;1;0;1;0}*{10; 20; 40; 10; 20; 30; 10}
and returns
{0; 0; 0; 10; 0; 30; 0}
Step 2 - Return the sum of those products
{0; 0; 0; 10; 0; 30; 0}
becomes
10 +30
and returns 40 in cell D10.
Example 4 - Use multiple logical expressions and mathematical operators
Mathematical operators between arrays allows you to do more complicated calculations, like this:
This example shows how to use multiple conditions. A number in cell range D2:D8 is added if California is found on the corresponding row in cell range B2:B8 OR if "Las Vegas" is found in cell range C2:C8.
* - Both logical expressions must match (AND logic)
+ - Any of the logical expressions must match, it can be all it can be only one. It doesn't matter. (OR logic)
The AND logic behind this is that
- TRUE * TRUE = TRUE
- TRUE * FALSE = FALSE
- FALSE * FALSE = FALSE
The OR logic works like this:
- TRUE + TRUE = TRUE
- TRUE + FALSE = TRUE
- FALSE + FALSE = FALSE
Formula in cell D10:
These expressions check if California is found in cell range B2:B8 or Las Vegas is found in cell range C2:C8. They are found in row 3, 5,7 and 8.
The sumproduct function sums the corresponding values in column D and returns 70 in cell D10. 20+10+30+10 equals 70.
Recommended articles
- SUMPRODUCT function (Microsoft Excel)
- SUMPRODUCT function (Xelplus)
- SUMPRODUCT Function (ExcelJet)
Articles with the 'SUMPRODUCT' Function
The following 5 articles have formulas that contain the SUMPRODUCT function.
How to do tiered calculations in one formula
The image above demonstrates a formula that calculates tiered values based on a tier table and returns a total. This […]
SUMPRODUCT – multiple criteria
The formula above in cell G8 uses two conditions in cell G2 and G3 and a date range G5:G6 to […]
SUMPRODUCT and nested IF functions
I have demonstrated in a previous post how to simplify nested IF functions, in this article I will show you how […]
You don't need to use the IF function in a SUMPRODUCT function, it is enough to use a logical expression. […]
The above image demonstrates how to ignore blank cells in a SUMPRODUCT formula. The following formula is shown in cell E3. […]
Functions in 'Math and trigonometry'
The SUMPRODUCT function function is one of many functions in the 'Math and trigonometry' category.
Converts negative numbers to positive numbers, in other words, the ABS function removes the sign. Excel Function Syntax ABS(number) Arguments […]
The ACOS function calculates the arccosine, or inverse cosine, of a number. Formula in cell C3: =ACOS(B3) Excel Function Syntax […]
The ACOSH function calculates the inverse hyperbolic cosine of a number. Formula in cell C3: =ACOSH(B3) Excel Function Syntax ACOSH(number) […]
The ACOT function calculates the inverse cotangent of a number. The returned angle is given in radians from 0 (zero) […]
The ACOTH function calculates the inverse hyperbolic cotangent of a number. Formula in cell C3: =ACOTH(B3) Excel Function Syntax ACOTH(number) […]
How to use the AGGREGATE function
The AGGREGATE function allows you to calculate different specific functions to a list or database. A special AGGREGATE function feature […]
The ASIN function calculates the arcsine of a number. The angle is in radians and is between -pi/2 to pi/2. =ASIN(B3) Excel […]
The ASINH function calculates the inverse hyperbolic sine of a number. =ASINH(B3) Excel Function Syntax ASINH(number) Arguments number Required. Any […]
The ATAN function calculates the arctangent of a number. The returned angle is in radians between -pi/2 to pi/2. =ATAN(B3) Excel […]
The ATAN2 function calculates the arctangent of an angle using specific x- and y-coordinates. The returned angle is in radians […]
The ATANH function calculates the inverse hyperbolic tangent of a number. =ATANH(B3) Excel Function Syntax ATANH(number) Arguments number Required. Must be […]
The BASE function converts a number into a text representation with a given radix (base). Formula in cell C3: =BASE(10, […]
How to use the CEILING function
The CEILING function rounds a number up to its nearest multiple. The number is rounded down if both the number […]
How to use the COMBIN function
The COMBIN function returns the number of combinations for a specific number of elements out of a larger number of […]
How to use the COMBINA function
The COMBINA function calculates the number of combinations for a given number of elements from a larger group of elements. Formula in […]
The COS function calculates the cosine of an angle. Formula in cell C3: =COS(B3) Excel Function Syntax COS(number) Arguments number […]
The COSH function calculates the hyperbolic cosine of a number. Formula in cell C3: =COSH(B3) Excel Function Syntax COSH(number) Arguments […]
The COT function calculates the cotangent of an angle specified in radians. Formula in cell C3: =COT(B3) Excel Function Syntax […]
The COTH function calculates the hyperbolic cotangent of a hyperbolic angle. The function has been available since Excel 2013. Formula […]
The CSC function calculates the cosecant of an angle (radians). The CSC function returns the same value as 1/SIN(number). Formula in […]
How to use the DECIMAL function
The DECIMAL function converts a text representation of a number in a given base into a decimal number. Formula in […]
How to use the DEGREES function
The DEGREES function calculates degrees from radians. Formula in cell C3: =DEGREES(B3) Excel Function Syntax DEGREES(angle) Arguments angle Required. The […]
The EVEN function rounds a number up to the nearest even whole number. An even number is a number that […]
Returns e raised to the power of a number, e equals 2.71828182845904. Example, e^2 equals 7.389056099 Formula in cell C3: […]
The FACT function returns the factorial of a number. Formula in cell C3: =FACT(B3) Example, 3! = 3*2*1 = 6 […]
How to use the FACTDOUBLE function
The FACTDOUBLE returns the double factorial of a number. Formula in cell C3: =FACTDOUBLE(B3) Excel Function Syntax FACTDOUBLE(number) Arguments number […]
How to use the FLOOR.MATH function
The FLOOR.MATH function rounds a number down to the nearest integer or to the nearest multiple of significance. Formula in […]
How to use the FLOOR.PRECISE function
The FLOOR.PRECISE function rounds a number down to the nearest integer or nearest multiple of significance. Excel Function Syntax FLOOR.PRECISE(number, […]
The GCD calculates the greatest common divisor that divides all given arguments without a remainder. Formula in cell D3: =GCD(B3:B4) Excel […]
Removes the decimal part from positive numbers and returns the whole number (integer) except negative values are rounded down to […]
The LCM function calculates the least common multiple. The least common multiple is the smallest positive integer that is a […]
The LN function calculates the natural logarithm of a number. Natural logarithms are based on the constant e. Formula in […]
The LOG function calculates the logarithm of a number to a specific base. Formula in cell C3: =LOG(10) Excel Function […]
The LOG10 function calculates the logarithm of a number using the base 10. Formula in cell C3: =LOG10(B3) Excel Function […]
How to use the MINVERSE function
The MINVERSE function calculates the inverse matrix for a given array. This function is useful for solving equations with multiple variables. […]
The MMULT function calculates the matrix product of two arrays, an array as the same number of rows as array1 and […]
The Mod function returns the remainder after a number is divided by a divisor. The Mod function is short for […]
How to use the MROUND function
The MROUND function calculates a number rounded to a given multiple. Formula in cell D3: =MROUND(B3,C3) Excel Function Syntax MROUND(number, […]
How to use the MULTINOMIAL function
The MULTINOMIAL function calculates the ratio of the factorial of a sum of values to the product of factorials. Formula […]
The MUNIT function calculates the identity matrix for a given dimension. Array formula in cell B2: =MUNIT(3) The formula above returns an […]
The PI function returns the number pi (¶). Formula in cell B3: =PI() Excel Function Syntax PI() Arguments PI function […]
The POWER function calculates a number raised to a power. Excel Function Syntax POWER(number, power) Arguments number Required. The number […]
How to use the PRODUCT function
The PRODUCT function returns the product of the numbers given in the argument. Formula in cell D3: =PRODUCT(B3:C3) Excel Function […]
How to use the RADIANS function
The RADIANS function converts degrees to radians. Formula in cell C3: =RADIANS(B3) Excel Function Syntax RADIANS(angle) Arguments angle Required. The […]
The RAND function calculates a random real number greater than or equal to 0 and less than 1. The function […]
How to use the RANDARRAY function
The RANDARRAY function returns a table of random numbers across rows and columns. It is located in the Math and […]
How to use the RANDBETWEEN function
Returns a random whole number between the numbers you specify. This function is volatile meaning a new random number is […]
How to use the ROUNDDOWN function
The ROUNDDOWN function calculates a number rounded down based on the number of digits to which you want to round […]
How to use the ROUNDUP function
The ROUNDUP function calculates a number rounded up based on the number of digits to which you want to round […]
The SEC function calculates the secant of an angle. Formula in cell E3: =SEC(B3) Excel Function Syntax SEC(number) Arguments number […]
The SECH function calculates the hyperbolic secant of an angle. Formula in cell C3: =SECH(B3) Excel Function Syntax SECH(number) Arguments […]
How to use the SEQUENCE function
The SEQUENCE function creates a list of sequential numbers to a cell range or array. It is located in the […]
How to use the SERIESSUM function
The SERIESSUM function calculates the sum of a power series based on the following formula: SERIESSUM(x, n, m, a) = […]
The SIGN function returns the sign of a number. 1 for a positiv number, 0 (zero) for a 0 (zero) […]
The SIN function calculates the sine of an angle. Formula in cell C3: =SIN(B3) Excel Function Syntax SIN(number) Arguments number […]
The SINH function calculates the hyperbolic sine of a number. Formula in cell C3: =SINH(B3) Excel Function Syntax SINH(number) Arguments […]
The SQRT function calculates the positive square root. Formula in cell C3: =SQRT(B3) Excel Function Syntax SQRT(number) Arguments number Required. […]
The SUM function in Excel allows you to add values, the function returns the sum in the cell it is […]
The SUMIF function sums values based on a condition. The condition can be applied to the values being summed or […]
How to use the SUMIFS function
The SUMIFS function in cell D11 adds numbers from column D based on criteria applied to column B and C. […]
How to use the SUMPRODUCT function
The SUMPRODUCT function calculates the product of corresponding values and then returns the sum of each multiplication.
The SUMSQ function calculates the sum of the squares of the arguments. Formula in cell D3: =SUMSQ(B3:B5) 2^2 = 4, […]
How to use the SUMX2MY2 function
The SUMX2MY2function calculates the sum of the difference of squares of corresponding values in two arrays. Formula in cell F3: […]
How to use the SUMX2PY2 function
The SUMX2PY2 function calculates the sum of the sum of squares of corresponding values in two arrays. The sum of […]
How to use the SUMXMY2 function
The SUMXMY2 function calculates the sum of squares of differences of corresponding values in two arrays. Formula in cell F3: […]
The TAN function calculates the tangent of an angle. Formula in cell C3: =TAN(B3) Excel Function Syntax TAN(number) Arguments number […]
The TANH function calculates the hyperbolic tangent of a number. Formula in cell C3: =TANH(B3) Excel Function Syntax TANH(number) Arguments number […]
The TRUNC function removes the fractional part of the number to an integer. Formula in cell C3: =TRUNC(B3) Excel Function […]
Learn how to use the SUBTOTAL function
The picture above shows row 4 and row 8 hidden, the SUM argument 9 sums all values in C3:C11 whereas […]
The quotient function returns the integer portion of a division. Example, 5/2 = 2.5. The integer is 2. Excel Function […]
3 Responses to “How to use the SUMPRODUCT function”
Leave a Reply
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Hi Oscar,
While reading this article "How to use excel SUMPRODUCT function" I detected what I think is a minor error.
In example 3 (The California-Los angeles example), you say that the formula transaltes to:
=({FALSE; TRUE; FALSE; TRUE; FALSE; TRUE; FALSE})*({FALSE; FALSE; FALSE; FALSE; FALSE; FALSE; TRUE})*{10; 20; 40; 10; 20; 30; 10}
but i think that the second set of boolean values is not correct and should be:
=({FALSE; TRUE; FALSE; TRUE; FALSE; TRUE; FALSE})*({FALSE; FALSE; FALSE; TRUE; FALSE; TRUE; FALSE})*{10; 20; 40; 10; 20; 30; 10}
Is that correct or I understood incorrectly?
Thanks in advance for your support with this blog.
Regards
Arturo
Arturo,
thanks!!
[…] SUMPRODUCT(array1, array2, ) Returns the sum of the products of the corresponding ranges or arrays […]