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

#### Table of Contents

- SUMPRODUCT function syntax
- SUMPRODUCT arguments
- Things to know about the SUMPRODUCT function
- How to use the SUMPRODUCT function
- How to use a logical expression in the SUMPRODUCT function
- How to use multiple conditions in the SUMPRODUCT function
- How to use OR logic in the SUMPRODUCT function
- Get Excel *.xlsx file

## 1. Excel Function Syntax

SUMPRODUCT(*array1*, [*array2]*, ...)

## 2. Arguments

array1 |
Required. Required. The first array argument whose numbers you want to multiply and then sum. |

[array2] |
Optional. Up to 254 additional arguments. |

## 3. Things to know about the SUMPRODUCT function

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.

## 4. How to use the SUMPRODUCT function

This example demonstrates how the SUMPRODUCT function works.

Formula in cell B7:

### 4.1 Explaining formula

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

## 5. How to use a logical expression in the SUMPRODUCT function

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:

### 5.1 Explaining formula

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

## 6. How to 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.

### 6.1 Explaining 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.

## 7. How to use OR logic in the SUMPRODUCT function

This example shows how to use multiple conditions. A number in cell range D3:D9 is added if the item in cell B12 is found on the corresponding row in cell range B3:B9 OR if the item in C12 is found in cell range C3:C9.

Formula in cell D10:

### Explaining formula in cell D10

#### Step 1 - Compare values to condition

The equal sign lets you compare the condition to values in B3:B9, the result is an array with the same size as B3:B9 containing TRUE or FALSE.

B3:B9=B12

becomes

{"Alaska"; "California"; "Arizona"; "California"; "Colorado"; "California"; "Nevada"}="California"

and returns

{FALSE; TRUE; FALSE; TRUE; FALSE; TRUE; FALSE}.

#### Step 2 - Compare values to condition

C3:C8=C12

becomes

{"Anchorage"; "San Diego"; "Phoenix"; "Los Angeles"; "Denver"; "Los Angeles"; "Las Vegas"}="Las Vegas"

and returns

{FALSE; FALSE; FALSE; FALSE; FALSE; FALSE; TRUE}.

#### Step 3 - Apply OR logic

We need to add numbers if at least one of the conditions matches on the same row, this means OR logic.

Mathematical operators between arrays allow you to do more complicated calculations, like this:

* (asterisk) - Both logical expressions must match (AND logic)

+ (plus sign) - 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 (1)
- TRUE * FALSE = FALSE (0)
- FALSE * FALSE = FALSE (0)

The OR logic works like this:

- TRUE + TRUE = TRUE (1)
- TRUE + FALSE = TRUE (1)
- FALSE + FALSE = FALSE (0)

The numbers above show the numerical equivalent of each result. True equals 1 and False equals 0 (zero).

The parentheses shown below let you control the order of calculation, we must do the comparisons before we add the arrays.

(B2:B8=B10)+(C2:C8=C10)

becomes

{FALSE; TRUE; FALSE; TRUE; FALSE; TRUE; FALSE} + {FALSE; FALSE; FALSE; FALSE; FALSE; FALSE; TRUE}

and returns {0; 1; 0; 1; 0; 1; 1}.

#### Step 4 - Check if result is larger than 0 (zero)

If both values match the conditions the result is two, the result will be twice as much. We can't multiply with two, the larger than character checks if the result is larger than 0 (zero).

((B3:B9=B12)+(C3:C9=C12))>0

becomes

{0; 1; 0; 1; 0; 1; 1}>0

and returns {FALSE; TRUE; FALSE; TRUE; FALSE; TRUE; TRUE}.

#### Step 5 - Multiply with numbers

((B2:B8=B10)+(C2:C8=C10))*D2:D8

becomes

{FALSE; TRUE; FALSE; TRUE; FALSE; TRUE; TRUE}*D2:D8

becomes

{FALSE; TRUE; FALSE; TRUE; FALSE; TRUE; TRUE}*{10; 20; 40; 10; 20; 30; 10}

and returns {0; 20; 0; 10; 0; 30; 10}.

#### Step 6 - Add numbers and return total

SUMPRODUCT(((B2:B8=B10)+(C2:C8=C10))*D2:D8)

becomes

SUMPRODUCT({0; 20; 0; 10; 0; 30; 10})

and returns 70.

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 rows 4, 6,8, and 9.

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)

### 'SUMPRODUCT' function examples

The following 79 articles contain the SUMPRODUCT function.

This post explains how to lookup a value and return multiple values. No array formula required.

Introduction In this post I am creating a spreadsheet that will calculate stock portfolio performance. To do this I am […]

Table of Contents AVERAGE ignore blanks Average - ignore blanks and errors Average - ignore blanks in non-contiguous cells Weighted […]

Question: I need to calculate how many hours a machine is utilized in a company with a night and day […]

The image above demonstrates a conditional formatting formula that highlights records that only exist in one table. There are two […]

In this blog post I will demonstrate a conditional formatting formula that will highlight common records in two lists. The […]

The array formula in cell D4 extracts the start dates for date ranges in cell range B3:B30, the array formula […]

The formula in cell B6 counts how many times the string (D3) is found in a cell value (B3) even […]

Table of Contents Count a specific text string in a cell Count text string in a range (case sensitive) Count […]

NETWORKDAYS function returns the number of whole workdays between two dates, however the array formula I am going to demonstrate […]

Janib Soomro asks: In A column, there are dates in mmddyyy format and in B column, there are two variables […]

The formula in cell F9 counts the number of cells in column B (Values1) that are equal to any of the […]

Table of Contents Count cells with text Count cells with text excluding cells containing a space character Count text values […]

How do I automatically count dates in a specific date range? Array formula in cell D3: =SUM(IF(($A$2:$A$10<$D$2)*($A$2:$A$10>$D$1), 1, 0)) + […]

Question: My issue is that I get the date in this format: 7/23/2011 7:00:00 AM I am trying to count […]

Question: Sam asks: Is there a formula that can count blocks For eg in your picture (see picture above) if […]

Joe asks: I have a worksheet that has rows, each containing sequential groupings of values of "1" and "0". These […]

Question: How do I count how many times a word exists in a range of cells? It does not have […]

This article describes a formula that counts values in two columns if they are duplicates on the same row. What's […]

The formula in cell B17 counts rows in cell range B3:D17 when at least one cell per row contains data. […]

If you want to count specific weekdays like for example Mondays and Wednesdays you need a more complicated array formula. […]

The formula in cell D18 counts unique distinct months in cell range B3:B16. Formula in D18: =SUMPRODUCT((FREQUENCY(DATE(YEAR($B$3:$B$16), MONTH($B$3:$B$16), 1), DATE(YEAR($B$3:$B$16), […]

The image above demonstrates three different formulas in column E that counts unique numbers unique distinct numbers duplicate numbers from […]

The image above shows a table with 3 columns containing random data. It is quite complicated trying to manually count […]

This article describes how to count unique distinct values. What are unique distinct values? They are all values but duplicates are […]

Steve asks: Right now I'm using the following formula to tell me how many of a specific defined day, ie […]

Question: How do I create a list of dates with blanks between each quarter? (Q1, Q2, Q3 and Q4) Answer: […]

This article describes how to create a random playlist based on a given number of teams using an array formula. […]

Excel has a great built-in tool for creating number series named Autofill. The tool is great, however, in some situations, […]

This article demonstrates how to set up dependent drop-down lists in multiple cells. The drop-down lists are populated based on […]

Mark G asks: 1 - I see you could change the formula to have the experssion COUNTIF($C$1:C1, $E$2:$E$5)<5 changed so […]

Anura asks: Is it possible to extend this by matching items that meet a criteria? I have a list of […]

This article demonstrates how to find empty cells and populate them automatically with a formula that adds numbers above and […]

The image above demonstartes an array formula in cell B34 that extracts empty hours in a weekly calendar. I have created […]

I found this excel question: I am a Controller in a multinational company. We have many transactions (sales, credits, debits, […]

This article demonstrates how to return the latest date based on a condition using formulas or a Pivot Table. The […]

This article demonstrates how to match a specified date to date ranges. The image above shows a formula in cell […]

This template makes it easy for you to create a weekly school schedule, simply enter the time ranges and the […]

The calendar shown in the image above highlights events based on frequency. It is made only with a few conditional […]

This article demonstrates a Conditional Formatting formula that lets you highlight cells based on numerical ranges specified in an Excel […]

This article shows you how to easily identify duplicate rows or records in a list. What's on this webpage Conditional […]

The image above demonstrates a conditional formatting formula that highlights duplicate items based on date. The first instance is not highlighted, […]

The image above shows you how to highlight rows with multiple criteria using OR logic. The criteria are found in […]

The picture above shows you conditional formatting formula that highlights matching records based on criteria in row 3 and 4. […]

I found an old post that I think is interesting to write about today. Think of two overlapping ranges, it […]

This article demonstrates a formula that calculates a running total. A running total is a sum that adds new numbers […]

The image above demonstrates a formula that calculates tiered values based on a tier table and returns a total. This […]

This article demonstrates formulas that will return the largest and smallest numbers, the corresponding column headers, the cell addresses, and […]

Table of Contents How to rank text uniquely without duplicates How to rank uniquely based on a condition Get Excel […]

The following formula ranks text values in column C uniquely based on the category in column B. Formula in D3: […]

In this article, I will demonstrate four different formulas that allow you to lookup a value that is to be found […]

The COUNTIF function is very capable of counting non-empty values, I will show you how in this article. Excel can […]

This article demonstrates formulas that show if a date range is overlapping another date range. The second section shows how […]

This article demonstrates formulas that perform a partial match for a given cell using multiple strings specified in cells F2 […]

I got a question a while ago about permutations, in essence how to find every permutation between 0 and 9 […]

Formula in B14: =INDEX(D3:D6, SUMPRODUCT(--(C10=B3:B6), --(C11=C3:C6), ROW(D3:D6)-MIN(ROW(D3:D6))+1)) Alternative array formula #1 in B15: =INDEX(D3:D6, MATCH(C10&"-"&C11, B3:B6&"-"&C3:C6, 0)) Alternative array formula […]

I will in this article demonstrate a calendar that automatically highlights dates based on date ranges, the calendar populates names […]

The picture above shows an Excel Table with Data Validation applied. An error dialog box appears if a user tries […]

Andrew asks: LOVE this example, my issue/need is, I need to add the results. So instead of States and Names, […]

Andre asks:I am trying to list people with the highest scores based on certain criteria. My data: column A B […]

Question: It's easy to sum a list by multiple criteria, you just use array formula a la: =SUM((column_plane=TRUE)*(column_countries="USA")*(column_producer="Boeing")*(column_to_sum)) But all […]

Katie asks: I have 57 sheets many of which are linked together by formulas, I need to get numbers from […]

I will now demonstrate with the following table how to add check-boxes and sum enabled check-boxes using a formula. Add […]

The formula in cell E14 adds a number from column C if the corresponding value in column B is unique […]

The formula in cell C15 uses two dates two to filter and then sum values in column C, the SUMIFS […]

This article explains how to build an array formula that sums numerical ranges. Example, I want to know how to […]

Question: I have a long table The key is actually col B&C BUT…sometime there are few rows with same key […]

The image above shows numbers in column B, some of these numbers are duplicates. The formula in D12 adds unique […]

Table of Contents Sum unique numbers Get Excel *.xlsx file Sum unique distinct numbers Get Excel *.xlsx file Sum number […]

In this post, I will provide a formula to sum values in column (Qty) where a column (Date) meets two […]

This article demonstrates ways to sum values based on criteria. Table of Contents SUMPRODUCT - based on a list of […]

You don't need to use the IF function in a SUMPRODUCT function, it is enough to use a logical expression. […]

I have demonstrated in a previous post how to simplify nested IF functions, in this article I will show you how […]

This article describes ways to work with the SUMPRODUCT function and blanks, error values, N/A# errors. Table of Contents SUMPRODUCT […]

This blog article describes how to create teams randomly. There are twenty names in column B and four teams in […]

This is follow up post to: Tracking a stock portfolio in excel (auto update) In this post we are going to […]

Question: I found a question here about tracking a stock portfolio. He would like to automatically create an overview table […]

Mark G asks in Create a random playlist in excel: Can this example be modified to create a true round-robin […]

This article demonstrates formulas that calculate the number of overlapping ranges for all ranges, finds the most overlapped range and […]

## Functions in this article

### Functions in 'Math and trigonometry' category

The SUMPRODUCT function function is one of many functions in the 'Math and trigonometry' category.

### Excel function categories

## Excel categories

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

**Contact Oscar**

You can contact me through this contact form

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 […]