How to Use OR Condition in SUMPRODUCT in Google Sheets

In this tutorial, I am going to explain the use of OR condition in SUMPRODUCT in Google Sheets.

SUMPRODUCT in Google Sheets is very handy. We can deviate from its core use. The real purpose of SUMPRODUCT is to find the product of two arrays that also equal in size. But you can use this function in a single array also but that would act as COUNTIF. Quite intriguing, right?

Don’t worry! In this tutorial that related to the use of OR condition in SUMPRODUCT in Google Sheets, I’ve included answers to your all questions related to the same.

The OR Condition in SUMPRODUCT in Google Sheets

I know I should start with the basic. Some of you may already know the use of SUMPRODUCT. But for a quick reference, see the basic use of SUMPRODUCT below. Also, you can check my Google Sheets Functions Guide.

Basic Example to Google Sheets SUMPRODUCT Function

Basic Example to Google Sheets SUMPRODUCT

In this, the formula in C7 is the product of two equal sized arrays, i.e. B2: B4 and C2: C4. In other words, it’s the sum of the products in Column D.

=B2*C2+B3*C3+B4*C4

Is there any other formula to find the product of two equal sized arrays?

See this formula.

=ArrayFormula(SUM(B2:B4*C2:C4))

SUMPRODUCT in Single Column in Google Doc Sheets

In the beginning, I have told you we can use SUMPRODUCT in a single column and that acts as a COUNTIF, right?

=sumproduct(A2:A="Apple")

This formula counts all the occurrences of the text “Apple” in column A and that’s equal to the below COUNTIF formula.

=countif(A2:A,"Apple")

How to Use the OR Condition in SUMPRODUCT in Google Sheets

We can use OR Logic in SUMPRODUCT to conditionally count or find the product. But we can’t use the OR Logical function directly in SUMPRODUCT. We can instead use the “+” sign as its equivalent.

The use of OR in SUMPRODUCT is different when the criteria are in the same column or in a different column/columns.

Let’s see how to use OR condition in SUMPRODUCT in Google Sheets in the same column first.

The OR in SUMPRODUCT in the Same Column in Sheets

Count Colum A if the value is either “Apple” or “Mango”.

OR in SUMPRODUCT in the Same Column

=SUMPRODUCT((A2:A="Apple")+(A2:A="Orange"))

Now to find the product of these two items, you can use the formula as below.

=SUMPRODUCT(((A2:A="Apple")+(A2:A="Orange"))*B2:B*C2:C)

The OR in SUMPRODUCT in Two Different Columns in Google Sheets

In the just above example, I’ve detailed how to use the OR in SUMPRODUCT in the same column in Google Sheets. Now see what happens when the columns are different.

It’s important to know how to use OR in two different columns in Sumproduct.

In the below example I want to count all the instances of “Crusher 1” in column B or “Gravel” in Column C.

OR in SUMPRODUCT in two different Columns

The formula counts all the cells containing the text “Crusher 1” in Column B. If the text is different then obviously it checks the texts in Column C for the text “Gravel” and counts it.

You can see the formula applied in Cell F3. How this formula differs from the previous one. Here I’ve wrapped the criteria with the function SIGN. Why? I will come to that. Before see how to find the product based on the OR in two different columns.

=Sumproduct(SIGN((B2:B7="Crusher 1")+(C2:C7="Gravel"))*D2:D7*E2:E7)

Now I will explain why should we use the SIGN function when we use OR condition in two different columns in Sumproduct in Google Sheets.

The Sumproduct OR Formula Logic

This is the criteria part in the above two formulas.

=(B2:B7="Crusher 1")+(C2:C7="Gravel")

Just apply this formula in any cell and see what this formula returns. It probably would return the value 0! Because Google Sheets won’t execute this formula as the cell references used are Arrays.

SUMPRODUCT is an array formula. So it works in SUMPRODUCT. But if you individually use this formula, you should include ArrayFormula with it. See this.

Logic behind the use of OR in SUMPRODUCT in two different Columns

For example, in the first row, it works like;

=(B2="Crusher 1")+(C2="Gravel")

i.e, TRUE+FALSE

The Boolean TRUE has the value of 1 and FALSE has the value of 0. So it returns 1.

The SUMPRODUCT finds the product as below.

Column D * Column E * the newly generated array

See the value in F4 which is 2. It causes wrong output in the SUMPRODUCT. We should convert this number to 1. The SIGN function does this.

That’s all about how to use OR condition in SUMPRODUCT in Google Sheets. Enjoy!

Related Reading:

1. How to Do a Case Sensitive Sumproduct in Google Sheets.

2. The Chart to Learn Text, Date, Numeric Criteria in Sumproduct Function in Google Sheets.

3. Compare Sumifs, Sumproduct, Dsum with Example in Google Sheets.

4. How to Use Date Difference as Criteria in SUMPRODUCT in Google Sheets.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Lookup Values Under Categories in Excel and Google Sheets

We can use a combination of XLOOKUP and VLOOKUP in both Excel and Google...

Extract Items Under a Category from the Same Column in Excel

In Excel, you can use a combination of the XLOOKUP and DROP functions to...

How to Create a Searchable Table in Excel Using the FILTER Function

Finding specific records, or rows containing the required information, is straightforward in Excel using...

Time Sequences in Excel by Minute, Hour, or Second Increments

Creating time sequences, whether by hour, minute, or second increments in Excel, can be...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.