SUMIFS in Google Sheets to sum cells with multiple criteria (AND / OR logic)

The tutorial shows how to use the SUMIFS function in Google Spreadsheets to sum cells with multiple criteria. You will find a handful of real-life SUMIFS formula examples with AND as wells as OR criteria.

Google Spreadsheets provide two functions to conditionally sum cells, SUMIF and SUMIFS. Regular visitors of our blog are already familiar with SUMIF that we covered last week, and today we are going to have a closer look at its plural version.

The difference between SUMIF and SUMIFS is as follows:

SUMIF can add up cells based on just one condition. If it is what you want, please check out this tutorial: SUMIF in Google Sheets.

SUMIFS can sum cells based on two or more conditions. Further on in this tutorial, you fill find a simple explanation of SUMIFS syntax and formula examples for different data types.

Google Sheets SUMIFS function - syntax & basic uses

The SUMIFS function is Google Sheets is designed to sum numbers with multiple conditions. Its arguments are as follows:

SUMIFS(sum_range, criteria_range1, criterion1, [criteria_range2, criterion2, …])

Where:

  • Sum_range(required) - the range to be summed.
  • Criteria_range1 (required) - the range of cells to be evaluated by criterion1.
  • Criterion1 (required) - the condition to be met by cells in criteria_range1.
  • Criteria_range2, criterion2, … (optional) - additional ranges and criteria to test.

SUMIFS in Google Sheets - 3 things to remember

Using SUMIFS formulas in Google spreadsheets is quite easy. To prevent most common errors, just remember these three simple facts:

  1. The SUMIFS function adds up only those cells that meet all conditions, i.e. all of the specified criteria are true for a cell. This is commonly referred to as AND logic.
  2. Sum range and all criteria ranges should be equally sized, i.e. have the same number of rows and columns, otherwise your SUMIFS formula will throw a #VALUE error.
  3. Depending on the nature of your conditions, build your criteria appropriately:
    • Text, wildcard characters and dates should be enclosed in quotation marks like "apples" or "*" or "4/19/2024".
    • Numbers and cell references are not enclosed in quotation marks when used on their own.
    • Logical operators with numbers, dates or text must be enclosed in double quotes like ">200", ">4/19/2024" or "<>apples" .
    • Logical operators used together with cell references and other functions require the quotes to begin a text string and ampersand to concatenate and finish the string off. For example: ">"&B1 or ">="&TODAY().

Okay, that's enough theory, let's build some useful formulas already!

How to sum with multiple criteria (AND logic)

When it comes to summing cells with multiple criteria, you may find a lot of different suggestions in Google groups and other user communities.

Let's say, you have a list of items in column A, amounts in column B, and delivery status in column C. Your goal is to get a total for a specific item with a certain delivery status, for example "apples" that are "delivered". How would you approach the task?

You may be surprised to know that many people still use array formulas for this purpose. For example, this one:

=ARRAYFORMULA(SUMPRODUCT((A2:A13="apples")*(C2:C13="delivered")*(B2:B13)))

What's wrong with this formula, you may ask me. Nothing except that it's excessively complex, difficult to understand and debug. It's like using a sledgehammer to crack a nut. Google Sheets SUMIFS function provides an easier way!

So, let's go ahead and define our arguments:

  • Column A should contain "apples". Assuming we have data in rows 2 to 13, our criteria_range1 is A2:A13, and criterion1 is "apples".
  • Column C should contain "delivered". Meaning, our criteria_range2 is C2:C13, and criterion2 is "delivered".
  • Numbers to sum are in column B, so our sum_range is B2:B13.

Putting the arguments together, we get this simple formula:

=SUMIFS(B2:B13, A2:A13, "apples", C2:C13, "delivered")

To add more flexibility, you can input both criteria in separate cells, say F1 and F2, and refer to those cells:

=SUMIFS(B2:B13, A2:A13, F1, C2:C13, F2)

As shown in the screenshot below, our SUMIFS formula works perfectly! SUMIFS in Google Sheets to sum cells with multiple criteria

Taking the example further, let's see how to use SUMIFS with other criteria types.

SUMIFS with logical operators

When your conditions are numbers or dates, use the comparison operators to express the criteria:

  • equal to (= or omitted)
  • not equal to (<>)
  • greater than (>)
  • less than (<)
  • greater than or equal to (>=)
  • less than or equal to (<=)

For example, to add up amounts in B2:B13 that are greater than or equal to 200 and delivered before 1-Apr-2024, use this formula:

=SUMIFS(B2:B13,B2:B13,">=200", C2:C13, "<4/1/2024")

In case you want to replace actual values with references to cells holding your criteria, please remember to enclose the logical operator in quotation marks and to concatenate the cell reference by using an ampersand:

=SUMIFS(B2:B13, B2:B13, ">="&F1, C2:C13, "<"&F2)

The screenshot below shows the result: SUMIFS formulas with logical operators

SUMIFS with other functions

In some situations, the conditions may depend on the results returned by some other functions. In this case, embed those functions in the criterion arguments of your SUMIFS formula.

As an example, let's sum "apples" that are "delivered". In other words, the delivery date is up to and including today, so we concatenate the "less than or equal to" operator (<=) with the TODAY() function:

=SUMIFS(B2:B13,A2:A13,F2,C2:C13,"<="&TODAY())

And get the following result: SUMIFS with other functions as criteria

SUMIFS with blank and non-blank cells

To sum numbers in one column depending on whether a cell in another column is empty or not empty, use one of the following criteria:

  • "=" to sum cells that are completely blank, i.e. contain absolutely nothing.
  • "" to sum empty cells including zero length strings.
  • "<>" to sum non-blank cells including zero length strings.

In case the Delivery date column contains some gaps, you may want to sum only those "apples" for which the delivery date is set, i.e. a cell in column C is not empty. The task can be accomplished with this formula:

=SUMIFS(B2:B13,A2:A13,"apples",C2:C13,"<>") SUMIFS to exclude empty cells

How to sum with multiple criteria (OR logic)

As you already know, by default, Google Sheets SUMIFS function works with AND logic - all conditions must match to be summed. In some situations, however, you may need to conditionally sum cells with OR logic, when any of the specified criteria is true. Below you will find a few possible ways to do this.

SUMIF with OR criterion (multiple criteria in the same column)

To sum cells with only a couple of criteria in the same column, you can simply add two SUMIF functions together.

For example, to sum the amounts in column B if column A is either "apples" or "bananas", use the SUMIF() + SUMIF() combination in its simplest form:

=SUMIF(A:A,"apples",B:B) + SUMIF(A:A,"bananas",B:B)

If you have three or more criteria, you may be looking for a more compact formula. For this, include the items in an array constant (aka inline array), use ArrayFormula to get a subtotal for each item, and wrap the whole construction into SUM() to add the subtotals together. For example:

=SUM(ARRAYFORMULA(SUMIF(A2:A13, {"apples", "bananas", "lemons"}, B2:B13)))

Instead of "hard-coding" the items in an array constant, you can enter them in individual cells, and include cell references in the array (in case of non-contiguous cells) or supply a range (in case of contiguous cells).

To better show you that our SUMIF formula works in exact accordance with the specified OR criteria, I've narrowed down the list to two items:

=SUM(ARRAYFORMULA(SUMIF(A2:A13, {E1, E2}, B2:B13)))

Or

=SUM(ARRAYFORMULA(SUMIF(A2:A13, E1:E2, B2:B13))) Sum cells with multiple OR criteria and output a total into one cell.

Instead of ArrayFormula, you can add up subtotals with the SUMPRODUCT function. For a short list of items, you can put it this way:

=SUMPRODUCT((A2:A13="apples") + (A2:A13="bananas"), B2:B13)

For multiple OR criteria (three or more items), you'd better use this syntax:

=SUMPRODUCT((A2:A13={"apples", "bananas"}) * B2:B13)

Replace the array elements with cells references, and you will get the most compact formula to sum cells with multiple OR criteria ever!

=SUMPRODUCT((A2:A13={E1, E2}) * B2:B13)

The screenshot below shows the result: A SUMPRODUCT formula to sum cells with OR criteria

Four different formulas, the same result. Which one to use is the matter of your personal preference :)

SUMIF with OR criterion and results in different cells

If you'd like to have a subtotal for each item in a separate cell, take an array SUMIF formula discussed above, adjust the references, and cut off the SUM() part:

=ARRAYFORMULA(SUMIF(A2:A13, {"apples", "bananas", "lemons"}, B2:B13))

This will give you a sum for each item in a separate cell as shown in the screenshot below: Sum with OR criteria and get sub-totals in separate cells.

For the sake of clarity, you enter the formula only in the leftmost cell (D2 in this example), and Google Sheets will put the results into as many cells as many items there are in your array constant. Just make sure you have enough empty cells to the right, otherwise, the result won't be expanded and the formula will turn into an error.

If you'd rather have subtotals in a column, then separate the array elements with semicolons to make a vertical array:

=ARRAYFORMULA(SUMIF(A2:A13, {"apples"; "bananas"; "lemons"}, B2:B13))

And the results will be output vertically in a column: Sum with OR criteria and output sub-totals in a column.

Tip. As usual, you can make your formula more flexible by replacing a hard-coded array with a range reference. That way, your users could type any items in the predefined cells, and you won't have to worry about updating your formula. For example, the formula shown in the screenshot above, can take the following shape:
=ARRAYFORMULA(SUMIF(A2:A13, D1:D3, B2:B13))

SUMIFS with OR criteria (multiple criteria in different columns)

This example shows how to sum numbers with several sets of conditions determined by the following logic.

  • Within each set, all conditions must be true (AND logic)
  • A cell is summed if any set of conditions is true (OR logic)

To make things easier to understand, please consider the following example. In our sample data set, supposing you want to sum amounts in column B if column A contains either "apples" OR "oranges" AND the delivery date in column C is "16-Mar-2018".

The most obvious way is to make two SUMIFS formulas to sum "apples" and "oranges" separately, and then add up the results:

=SUMIFS(B2:B13, A2:A13, "apples", C2:C13, "16-Mar-2024") +
SUMIFS(B2:B13, A2:A13, "oranges", C2:C13, "16-Mar-2024")

Or, you can enter your criteria in some cells, as shown in the screenshot below: SUMIFS with OR criteria

Regrettably, Google Sheets do not allow expressing multiple OR conditions using array constants, therefore we cannot make a plural version of our SUMIF with OR criteria formula. Luckily, there is another way to achieve the same result with a bit shorter formula - the SUPRODUCT function.

As an example, let's enter the desired delivery date (AND criterion) in F2 and items (OR criteria) in contiguous cells, say F1 and G1. Now, you can use the following formula to sum numbers in B2:B13 based on the above criteria:

=(SUMPRODUCT(--(C2:C13=F2), (--(ISNUMBER(MATCH(A2:A13, F1:G1, 0)))), B2:B13)) A SUPRODUCT formula to sum cells with multiple OR criteria

How this formula works

Working from the inside out, here's what you do:

  • Check if an item is "apple" or "orange":
    ISNUMBER(MATCH(A2:A13, F1:G1,0))

    As the result, you'll get an array or TRUE and FALSE values (TRUE if any of the specified criteria is met, FALSE if none of the criteria is met).

  • Compare a list of dates with the target date: C2:C13=F2

    Instead of a cell reference, you can enter the date directly in a formula by using DATEVALUE or DATE function. For example, C2:C13=DATEVALUE("3/16/2024") or C2:C13=DATE(2024,3,16)

    In this formula, however, you cannot compare a range with a date directly, like C2:C13="3/16/2024" or C2:C13="16-Mar-2024", because you'd be comparing a cell with a date to a text string. Google Sheets won't understand that and you will most likely get a zero result.

    If done correctly, this comparison will give you another array or TRUE and FALSE.

  • Use the double unary operator (--) to coerce both arrays of TRUE and FALSE to 1 and 0, respectively.
  • Supply the range to sum: B2:B13

SUMPRODUCT will first multiply the elements of 3 arrays (two arrays of 0's and 1's and an array of numbers in B2:B13), and then sum the products. Because multiplying by 0 always yields 0, only the cells that have 1 in the first two arrays will "survive". As the result, only the amounts with the specified delivery date and item names will be summed.

This is how you use SUMIFS in Google Sheets to sum cells with multiple conditions. To have a closer look at the formulas discussed in this tutorial, I invite you to open our SUMIFS Google Sheets Examples. I thank you for reading and hope to see you on our blog next week!

Spreadsheet with formula examples

SUMIFS Google Sheets Examples (make yourself a copy)

Table of contents

181 comments

  1. Hi All!
    How can I do a NOT statement...
    =SUMIFS( Range, Criteria Range, NOT "A")

    Thanks! (Example please?) . ;-)
    Robert

  2. Can I use this to count checkboxes?
    If so, what is the function?

    • To count checkboxes, you need to use the COUNTIF function. You can learn more about it here.

      Since Google sees checkboxes as TRUE (checked) or FALSE (unchecked), your formula should be like this:
      =COUNTIF(A2:A10,TRUE)
      where A2:A10 is the range with checkboxes and you count those that are checked. To count those unchecked, replace TRUE with FALSE.

  3. Hi guys i only want to know how to turn the result to "0" if one values is = "0"
    For Example A1 = 500 and A2 = 0 i want to sum them but i want the result to turn "0" because A2 has no value indicated. can you show me what formula should i use.. pls. help im only new to this spreadsheet thing.

    Thank you very much in advance.
    and God Bless.

    • Hi Harley,

      I believe SUMIF is not enough since the logic of your calculation contains two conditions that lead to different results - one for when A2 is 0, and the other when it's not. Thus, I'd recommend trying this formula:
      =IF(COUNTIF(A1:A10,"=0"),0,SUM(A1:A10))

      I indicated the range A1:A10 just for this example, but you can adjust it according to your data.

      You can learn more about the IF function here.

  4. How would I create my or argument if the arguments were numbers? For instance, what if you wanted to sum all of the orders that came to a certain dollar amount? This would make a task at work a lot easier.

    • Carlos,

      I'm sorry but your question is not entirely clear.
      Could you provide an example and explain the task in detail? If so, feel free to share your sample spreadsheet with support@4-bits.com with the data you have and the result you'd like to get. Please include the link to this comment as well.
      I'll look into your task and see what I can do.

  5. Hi, I have a sheet with Column A consisting of Dates, Column B consisting of Mango, Banana, Pineapple, Blueberry and Column C of their respective Prices. My query is, to sum all the fruits right from the first date till the latest date but want to exclude only Mango price right from first date except the latest date. Any help is appreciated. Thanks in advance!

    • Hi Ravinder,

      I'm sorry but the part with Mango is not really clear. For us to understand your task better, feel free to share a small sample spreadsheet with us (support@4-bits.com) with your source data and the result you expect to get. Just make sure to shorten the table to 10-20 rows and provide the link to this comment as well.
      Thank you.

  6. Hi. I have sheet with a drop down cell with three ranges ( RW -rework, WD - warehouse damages and Re-pack). In one cell I have a formula to count the value of RW in one day. I was asked to ad in the drop down cell the range Re-pack to be added on the value of rework. I trayed to ad this range " Re-pack" in the formula but is not working. The formula is : =SUMIF(C5:C,ʺWDʺ,G5:G)and I would like to ad in this formula the range "Re-pack" to be counted in the same cell where is added the value of "RW".

  7. Amazing, Thank you

  8. I have my data base in columns, and one of them is showing quarters as (1, 2, 3, 4).
    in my lookup sheet, i created an additional periods as a drop down menu (1,2,H1,3,Q3YTD,4,H2, TY)...
    In the same Sumifs, everything works well with 1, 2, 3, 4, --- but i need a way where when i select H1, it can add both 1 and 2... etc...

    can anyone help.

  9. what formula do I use when taking two numbers from different cells and have them equal complete sets. Example 20 RH, 55 Lh = 20 complete sets.

    • Thank you for contacting us, Virginia.
      I'm sorry but your task is not entirely clear. If you could describe it a bit more, we may be able to advise the solution.
      Thank you.

  10. I have a sumifs formula working right now for a running total. I now want to use the same formula to only calculate the amounts over or under 0, but do not know how to add this into the criteria. Can anyone help? The formula I am using that is working for the total is this..
    =sumifs('2019 Balance Sheet'!E:E,'2019 Balance Sheet'!B:B,"Saver",'2019 Balance Sheet'!C:C,"Car",'2019 Balance Sheet'!D:D,"Fuel")
    How do I then total only the amounts greater than 0 to track deposits in another cell, and only amounts less than 0 in another cell for withdrawals.

    • Thank you for your comment, Lara,

      You simply need to add a couple of more arguments: the range and the additional condition: '2019 Balance Sheet'!E:E,"<0"
      So the entire formula will look like this
      =SUMIFS('2019 Balance Sheet'!E:E,'2019 Balance Sheet'!B:B,"Saver",'2019 Balance Sheet'!C:C,"Car",'2019 Balance Sheet'!D:D,"Fuel",'2019 Balance Sheet'!E:E,"<0")

      For another formula, change the condition "<0" to ">0".

      • Brilliant! Thanks so much, I was trying something like this but wasn't getting the " & ' correct but knew I was close.

  11. Hi! I'm trying to make a SUMIFS formula to sum up expenses where one of the criteria is date, but i have two columns with dates (Column A - Date Purchased and Column S - Date Paid). Column S only has entries when it is different from Column A, otherwise it is blank.

    So for the criteria range, I want to use column S if it has entries, otherwise I want to use column A.

    My current formula only makes use of Column A for now and I don't know how to go about it. :(

    Can you please help me? Thank you!

  12. Hello! I'm need a help. In de picture 2, why expression
    SUMIFS(B7:B15 , MONTH(C7:C15), "May", a7:e15, "Oranges")
    return #error?
    Thanks.

    • Hi Cleomir,

      The SUMIFS function does not accept anything but ranges in criteria_range arguments, therefore MONTH(C7:C15) won't work.

      Instead, try using this SUMPRODUCT formula:
      =SUMPRODUCT(--(MONTH(C7:C15)=5)*(A7:A15="Oranges")*(B7:B15))

  13. Despite using the correct formula in Google sheets(or at least i think I am) , I get 0 when the calculation is done, even though I should get a sum. Any idea of why this could happen ?

    • Hi Irina,

      If you could share your sheet or at least post a formula here, we will try to figure it out.

    • Hi Irina,

      If you're trying to use "or" logic, Google Sheets's SUMIFS function does not currently support this. It only supports "and" logic - i.e., Google Sheets will only sum the cells that match all of the criteria you enter into the SUMIFS formula.

  14. its not only just in amount and items because i cannot solve it because mine is for department i need to know how can i solve it

    • Charlene:
      SUMIF can add up cells based on just one condition. If this is what you want, please check out this tutorial: SUMIF in Google Sheets with formula examples. https://www.ablebits.com/office-addins-blog/sumif-google-sheets/
      SUMIFS can sum cells based on two or more conditions. In this tutorial, you fill find a simple explanation of SUMIFS syntax and formula examples for different data types. f this is what you need scroll to the top of this page where you can begin the tutorial.

  15. I want a SUMIF formula about Departments i want an example of that can you give atleast 2?

  16. I wanted to use sumifs in five different sheets with assistance of a drop down list. Any help.

  17. Please help.......
    I want to count the number of individual product an agent sold in a Sunday thru Saturday date range, using two google sheets.
    Sheet1 has each transaction starting by 00/00/00.
    Sheet2 is the summary page starting with the week, agent, each product-- for 5 weeks, then on to the next agent.

  18. I am looking for a formula.
    And the conditions are :
    If B1, C1, D1, E1, F1, G1. all values are >0 ...then H1=400

    If B1, C1, D1, E1, F1, all values are >0 ...then H1=300

    If B1, C1, D1, E1. all values are >0 ...then H1=250

    If B1, C1, D1,. all values are >0 ...then H1=200

    If B1, C1 all values are >0 ...then H1=150

    If B1 is >0 ...then H1=100

    If (B1:G1)= 0 ...then H1 = 0

    • You are assuming that the numbers are all POSITIVE and in non-ascending order from B1 -> G1. That is, if B1 & C1 are positive, but D1 is zero, that E1,F1 and G1 will also be zero. Etc.
      In that case, the following formula will do the job (at H1):
      =choose(countif(B1:G1,">0")+1,0,100,150,200,250,300,400)

  19. I have a list of names in cells from G1:G20 (which can be increased later); I want that when I input one of the names in the list in D1:D500, the result in B1:B500 should read “CIS”.
    Can someone give an excel formula, please for this statement?
    Regards
    Emanuel

    • Hi Emanuel,

      Enter the below formula in B1, and then copy it up to B500:
      =IF(COUNTIF(G:G, $D1)>0, "CIS", "")

  20. GreetingsMs. Svetlana Cheusheva,
    I'm in kind request of your assistance,
    I am working with stock which i normally issue out weekly.
    i have different columns, opening balance, quantity received, quantity issued, closing balance among others. you realise i have a formula in the 'closing balance' column that automatically calculates; (=opening+received-closing). i have another column 'number of days out of stock'. this column includes the number of days of a month (out of 30 or 31) for which the item had stocked out.
    example: if i opened with 30 items on 1st march, i received 20 on 10th,
    i issued out all the 50 on 21st to remain with 0, then the days out of stock is 31-21=10
    * i issued out all the 50 on 21st to remain with 0, but more is received on 25th then days out of stock will become 25-21=4.
    i need a formula that will automatically read when the 'current stock' column becomes zero and then subtracts to return the days out of stock.
    (i dont mind if the formula i am looking for assumes all months have 30 days).
    *(actually even if its not possible to meet the second condition, i will settle with that)
    thank you in advance

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)