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 "3/15/2018".
    • 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", ">3/11/2018" 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((A6:A14="apples")*(C6:C14="delivered")*(B6:B14)))

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 6 to 14, our criteria_range1 is A6:A14, and criterion1 is "apples".
  • Column C should contain "delivered". Meaning, our criteria_range2 is C6:C14, and criterion2 is "delivered".
  • Numbers to sum are in column B, so our sum_range is B6:B14.

Putting the arguments together, we get this simple formula:

=SUMIFS(B6:B14, A6:A14, "apples", C6:C14,"delivered")

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

=SUMIFS(B6:B14, A6:A14, B1, C6:C14, B2)

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 B6:B14 that are greater than or equal to 200 and delivered before 1-Apr-2018, use this formula:

=SUMIFS(B6:B14,B6:B14,">=200", C6:C14, "<4/1/2018")

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(B6:B14,B6:B14,">="&B1, C6:C14, "<"&B2)

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(B6:B14,A6:A14, B2,C6:C14, "<="&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(B6:B14,A6:A14,"apples" ,C6:C14, "<>")

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 eample:

=SUM(ARRAYFORMULA(SUMIF(A6:A14, {"apples", "bananas", "lemons"}, B6:B14)))

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(A6:A14, {B1, B2}, B6:B14)))

Or

=SUM(ARRAYFORMULA(SUMIF(A6:A14, B1:B2, B6:B14)))

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((A6:A14="apples") + (A6:A14="bananas"), B6:B14)

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

=SUMPRODUCT((A8:A16={"apples", "bananas"}) * B8:B16)

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

=SUMPRODUCT((A8:A16={B1, B2}) * B8:B16)

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(A5:A13, {"apples", "bananas", "lemons"}, B5: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 (A2 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 some of your data may be overwritten.

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

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

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:A10, D1:D3, B2:B10))

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(B6:B14, A6:A14, "apples", C6:C14, "16-Mar-2018") +
SUMIFS(B6:B14, A6:A14, "oranges", C6:C14, "16-Mar-2018")

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 B2 and items (OR criteria) in contiguous cells, say B1 and C1. Now, you can use the following formula to sum numbers in B6:B14 based on the above criteria:

=(SUMPRODUCT(--(C6:C14=B2), (--(ISNUMBER(MATCH(A6:A14, B1:C1, 0)))), B6:B14))

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(A6:A14, B1:C1,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: C6:C14=B2

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

    In this formula, however, you cannot compare a range with a date directly, like C6:C14="3/16/2018" or C6:C14="16-Mar-2018", 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: B6:B14

SUMPRODUCT will first multiply the elements of 3 arrays (two arrays of 0's and 1's and an array of numbers in B6:B14), 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!

You may also be interested in

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

  1. Kristi Linst says:

    Hi! I have a super easy one for you but for some reason I just can't get my array formula to work. I need a list of sum of column C for each combination of Comumn A & Comumn B that currently exists.

    Example data:
    Lindsay Mitchelle 19
    Staci Elvers 9
    Shelia Jacobs 19
    Staci Elvers 17
    Lindsay Mitchelle 18
    Shelia Jacobs 20
    Lindsay Stamon 7

    What I need the results to be is:
    Lindsay Mitchelle 37
    Staci Elvers 26
    Shelia Jacobs 39
    Lindsay Stamon 7

    Here's a sheet with some more example data:
    https://docs.google.com/spreadsheets/d/1GNgV_s_o5gclVGqi02bEKAdZKBz7ZCp8fbJe9_nBkdI/edit?usp=sharing

    • Hi Kristi,

      Please add the desired result directly to the file. You see, I don't know whether you need it on the same sheet or other certain cells. Also, do you use a list of all names that appear in a column somewhere? If so, please include it as well. Thank you.

  2. Lloyd V. says:

    Hi goodmorning. Can you help me in formula I'm a beginner on this field.
    this is my formula
    =SUMIFS('Order File'!E:E,"1299"'Order File'!F:F,"GOLD WATCH",'Order File'!D:D,"DELIVERED")
    i need the total for the gold watch that was delivered and the amount is 1299, but there are other gold watch that has other amount. do i need to use "IF" function inside "SUMIFS? thank you

  3. Ritessh Jaiin says:

    Hey Guyz, can anyone help with this formula?

    =SUMIFS(ImportRange("1j_7JWjcC9I5I_erUOCj0TnVKn7mvveBdPuy89pWKJb8",'Master Deal Data'!$C$2:$C), ImportRange("1j_7JWjcC9I5I_erUOCj0TnVKn7mvveBdPuy89pWKJb8",'Master Deal Data'!$BG$2:$BG),$B3, ImportRange("1j_7JWjcC9I5I_erUOCj0TnVKn7mvveBdPuy89pWKJb8",'Master Deal Data'!$BH2:$BH),2021)

    Here $B3 is the month name like 'January'...
    If I try CountIfs, it works perfectly but when I try this formula i.e. SUMIFS it shows me 'Argument must be a range'.
    If i use this formula directly in the sheet with which I am linking using Importrange function, it works too...

    Please anyone help.

  4. Danny says:

    Hi I would like to combine these 2 formulas into 1 using SUMIFS or whatever it is I need but I am having a hard time. They both work correctly individually.

    The first formula below looks through a column of hours and sums them only if they fall within range of a month. For example, it will sum only if hours were entered in January 2022. (A1 is the date for example 1/1/2022)

    =sumifs(G7:G805,H7:H805,">="&DATE(YEAR(A1),MONTH(A1),1),H7:H805,"<="&EOMONTH(A1,0))

    The 2nd formula sorts through a column and sums them only if a "SUBJECT TAUGHT" matches. (In my example it sums up only if Pathology was lectured.

    SumIF(I7:I37,"Pathology",G7:G37)

    Basically I am trying to nest or combine them so that it sums up the subject taught only if it falls within a month/date range.

    • Hi Danny,

      If I understand you correctly, you just need to add the criteria_range & the criterion from the second formula into the first one:
      =sumifs(G7:G805,H7:H805,">="&DATE(YEAR(A1),MONTH(A1),1),H7:H805,"<="&EOMONTH(A1,0),I7:I805,"Pathology")

      However SUMIFS requires all arguments to be of the equal size, so you'll have to extend I7:I37 to I7:I805.

      If this doesn't work for you, please share a small sample spreadsheet with us (support@apps4gs.com) with 2 sheets: (1) a copy of your source data (2) the result you expect to get (the result sheet is of great importance and often gives a better understanding than any text description). I kindly ask you to shorten the tables to 10-20 rows.

      Note. We keep that Google account for file sharing only and don't monitor its Inbox. Once you share the file, just confirm by replying to this comment.

      I'll look into it.

      • PAULINE S. says:

        Hi, I'm having a similar issue. I have two sheets within a document: Sheet 1, "Pedidos" with a list of transactions showing date, quantity and price in the columns; Sheet 2, "Sumario Mensal" with a summary of products sold within the month for all of 2022.

        When I use SUMIFS to calculate quantity "quantidade" sold within a date range, it returns the correct value: =SUMIFS(Pedidos!$C$3:$C,Pedidos!$A$3:$A,">="&F$1,Pedidos!$A$3:$A,"="&F$1,Pedidos!$A$3:$A,"<="&EOMONTH(F$1,0),Pedidos!$B$3:$B,"="&B3)

        However, when I try to combine both formulas Sheets doesn't recognize the second formula as criteria_range 3, criterion. It keeps reading it as criteria_range 2. Have you ever seen anything like this?

        I'll share the Sheet with the email you mentioned and if you guys can help me, it would be awesome!

  5. Agus Hidayat says:

    Hi Natalia,

    i would like to have a formula to SUM a range in column D with criteria in column F (with text "x" or any number), the SUM are from row D2:D6.
    i was try with this formula LOOKUP(1;1/(F2:F10);F2:F10) to find the last filled cell but i can not found how to combine with the SUM formula just to SUM from D2:D6 with said criteria.
    with the criteria i do expect to able to calculate or SUM until any criteria as filled cell in column F. (text or any number)

    A B C D E F
    1 BALANCE PROFIT PROP+BAL WD LAST BALANCE TO SUM
    2 100,00 13,00 113,00 1,30 111,70
    3 111,70 14,52 126,22 1,45 124,77
    4 124,77 16,22 140,99 1,62 139,37
    5 139,37 18,12 157,48 1,81 155,67
    6 155,67 20,24 175,91 2,02 173,89 x
    7 173,89 22,61 196,49 2,26 194,23
    8 194,23 25,25 219,48 2,53 216,96
    9 216,96 28,20 245,16 2,82 242,34
    10 242,34 31,50 273,84 3,15 270,69

    WD up to "x" : 8,21

    i do appreciate i you can share me the formula and many thanks for your kind support.

    salam,
    agus.

      • Agus Hidayat says:

        Wow....
        this is really amazing formula, first i put as a normal formula and the result is ERROR with error message #VALUE!.
        i was try to execute every single formula on those but still error then i realize that this is an array formula so i press CTRL-SHIFT-ENTER when executing the formula and it is working fine.

        really really appreciate for quick response and thanks a bunch for the shared formula.

        salam,
        agus.

  6. Les Sullivan says:

    Hi, I am at my wits end. I have been trying to use countifs and sumifs to generate results in a table with no luck. Long story short, My data sheet is A1:K150, Column G has a dollar value (Dollar Amount), Column G, text/number combo (reason code) and Column J is text (Action Taken)
    Example 1 that I could get Reason code is R13, I needed to count the times Reason code R13 was taken as a loss
    Formula used with success is =COUNTIFS($H$3:$H$150,"R13",$J$3:$J$150, "Loss")

    Now what I am trying to do is take the sum of the amount in column g and include it to the same results. Rather than count how many, I would like to sum to total of Column G where Column H is matches the reason code and column J is the action taken. IE Sum of items for R13 taken as loss.

    Any help would be greatly appreciated.

  7. Brenda Parker says:

    So I did a Sumifs function to add up day pay within the date range of the pay period...easy stuff because it's a basic sum.

    What I would love to do (but can't quite figure it out) if write something similar but to subtract (clock in and clock out times) also within a date range.

    I'm just savy enough to be dangerous...am I wasting my time trying to figure this out? Is it even possible to find a difference in two cells with date range criteria?

    • Hello Brenda,

      For me to be able to help you, please create a sample spreadsheet with 2 sheets: (1) a sample of your data (2) the result you expect to get; and share it with us – support@apps4gs.com. The result sheet is of great importance and often gives us a better understanding than any text description. I kindly ask you to shorten the tables to 10-20 rows. If you have confidential information there, you can replace it with some irrelevant data, just keep the format.

      Note. We keep that Google account for file sharing only and don't monitor its Inbox. Please do not email there. Once you share the file, just confirm by replying to this comment.

      I'll look into your task and do my best to help.

  8. Scott says:

    Hi! I have a very complex formula (for me) that works in excel, but not Sheets. Can anyone show how to convert this for Sheets? It appears that I need the OR logic for the value arrays in SUMIFS and COUNTIFS, but my childish attempts to solve this have failed.

    The article gives two options for OR logic using the non-S version, but it seems I still need to retain the S version of these functions. Any help is appreciated.

    =IFERROR(SUM(SUMIFS(Sets!H:H,Sets!E:E,A9,Sets!C:C,{235,364,405,412,416,423,469},Sets!J:J,">="&OSS!$B$3,Sets!G:G,">"&$B$4,Sets!F:F,">="&$B$5))/SUM(COUNTIFS(Sets!E:E,A9,Sets!C:C,{235,364,405,412,416,423,469},Sets!J:J,">="&OSS!$B$3,Sets!G:G,">"&$B$4,Sets!F:F,">="&$B$5)),"")

    • Scott says:

      I solved my issue using the formula below. Regexmatch is needed for SUMIFS I guess. Along with some shuffling of the functions.

      =IFERROR(ArrayFormula(SUMIFS(Sets!H:H,Sets!E:E,A9,REGEXMATCH(Sets!C:C,"^(235|364|405|412|416|423|469)$"),TRUE,Sets!J:J,">="&OSS!$B$3,Sets!G:G,">"&$B$4,Sets!F:F,">="&$B$5))
      /SUM(ARRAYFORMULA(COUNTIFS(Sets!E:E,A9,Sets!C:C,{235,364,405,412,416,423,469},Sets!J:J,">="&OSS!$B$3,Sets!G:G,">"&$B$4,Sets!F:F,">="&$B$5))),"")

  9. Alex says:

    Hello, In the spreadsheet below, on the first sheet called "Payouts", I am currently using Sumif in column B to total up values in column H from the second sheet called "Worksheet" if the name in the drop down column A matches any of the names in "Worksheets" column A.

    I want to add a criteria that the Checkbox in column D in "Worksheet" be checked (=True) to include that row in the sum.

    https://docs.google.com/spreadsheets/d/1qowl-flGEafWZJCvlf07GCrOWqsfdo68w8XA_S8Uad0/edit?usp=sharing

  10. Giulia says:

    Hello,
    from AL to BO i have scores (they range from 1 to 3) and from BS to CV i have the matching values either a or b or c. I would like to match total scores for a, b, or c for each row (one individual who completes a test).
    I have tried many formulas that at best gives me a 0 or an error.
    for example:
    =SUMIFS(BS3:CV3;"a";AL3:BO3) gives a 0
    =SUMIFS(AL2:AO2,BS2:BT2,"a") gives an #ERROR

    am I trying something impossible to solve or could you provide me with some hints?
    Thanks in advance for your time.

    • Hello Giulia,

      For me to be able to help you, please create a sample spreadsheet with 2 sheets: (1) a sample of your data (2) the result you expect to get; and share it with us – support@apps4gs.com. The result sheet is of great importance and often gives us a better understanding than any text description. I kindly ask you to shorten the tables to 10-20 rows. If you have confidential information there, you can replace it with some irrelevant data, just keep the format.

      Note. We keep that Google account for file sharing only and don't monitor its Inbox. Please do not email there. Once you share the file, just confirm by replying to this comment.

      I'll look into your task and do my best to help.

  11. Dyn says:

    Hey, how can I make this work for even or odd rows? Here’s what I’ve come up so far, but it says the argument must be a range:

    =SUMIF(ISEVEN(ROW(C62:C76)),""&"",ISEVEN(ROW(A62:A76)))

    • Hey Dyn,

      To sum numbers from the even rows, try a formula like this:
      =SUM(FILTER(C62:C76,ISEVEN(ROW(C62:C76))))

      If this doesn't work as you expect, for me to be able to help you, please consider sharing an editable copy of your spreadsheet with us (support@apps4gs.com) with 2 sheets: (1) a copy of your data (2) the result you expect to get (the result sheet is of great importance and often gives us a better understanding than any text description). I kindly ask you to shorten the tables to 10-20 rows. If you have confidential information there, you can replace it with some irrelevant data, just keep the format.

      Note. We keep that Google account for file sharing only and don't monitor its Inbox. Please do not email there. Once you share the file, just confirm by replying to this comment.

      I'll look into your task.

  12. Zach says:

    This was extremely useful! Thank you so much!

    The equations with provided examples was so much clearer than other "support" I had found previously.

  13. Peesot says:

    Hi, is it possible to include importrange with sumif? I wanted to sum data from a spreadsheet, criteria is date and sum range is amount. I would like this to be entered into a different spreadsheet.

    • Hi Peesot,

      My apologies for the late reply, I somehow missed your comment.

      Well, at the moment SUMIF does work with IMPORTRANGE but only if first you transfer the required range with a separate IMPORTRANGE and give the function permissions to access another spreadsheet. Otherwise, your SUMIF will return 0.

      You will find the tutorial on IMPORTRANGE in this blog post.

  14. ravi says:

    Hi,
    I'm hoping you can help me with a formula.
    arrayformula with sum function a1+a2,a3+a4,a5+a6..................pair 2-2-2
    and a1+a2+a3,a4+a5+a6,a7+a8+a9....................Pair 3-3-3

  15. Katy says:

    I'm hoping you can help! I've read through all of the queries above hoping someone would be trying to do the same thing as me and have searched other forums as well.

    Basically, I want a sum of the values in column J the value in column D is "Law" and the value in column F is "2021". The formula below returns a result of 0. What am I doing wrong?

    =SUMIF(AND('2021 EO Sales'!D:D,"Law",'2021 EO Sales'!F:F,"2021"),'2021 EO Sales'!J:J)

    • Hello Katy,

      You're trying to sum based on two conditions using SUMIF. The SUMIF function adds up based on one condition only. The AND function won't help there.
      To sum by several conditions, you should use SUMIFS instead. It's the function described in this blog post (see above). Please look through it closely and you will be able to build the correct formula.

  16. NICOLE WALL says:

    Hi,
    I'm hoping you can help me with a formula. I have attempted to look through many forums but not quite been able to find what I'm looking for.
    I am attempting to sum multiple columns with multiple criteria that also relies on criteria from other columns and one of those has multiple criteria as well.
    Below is the outcome I am looking for
    Desired result for cell I18
    SUM all columns S,W,AA,AE,AI,AM
    IF columns
    H = AA
    K = W
    J = Jul19|Aug19|Sep19|Oct19|Nov19|Dec19|Jan20|Feb20|Mar20|Apr20|May20|Jun20
    R,V,Z,AD,AH,AL = Jul19|Aug19|Sep19|Oct19|Nov19|Dec19|Jan20|Feb20|Mar20|Apr20|May20|Jun20
    Please see below the link to the spreadsheet - this could be restricted so please let me know if you are unable to open
    https://docs.google.com/spreadsheets/d/1sOSPZ0RNObSuEdGg1YvndN_alXu77AU0QGy7J2cE0hs/edit#gid=0
    I hope to hear from you. I am desperate!

    • Hi Nicole,

      Yes, the access to your spreadsheet is denied. For us to be able to help you, please share it with us directly: support@apps4gs.com. Please include a sheet with the result you expect to get as well.
      Note. We keep that Google account for file sharing only, please do not email there. Once you share the file, just confirm by replying here.
      Thank you.

  17. Michael Holland says:

    Hi,

    I'm trying to use the SUMIF/SUMIFS OR criterion with wildcards i.e. as in your example above but

    =SUM(ARRAYFORMULA(SUMIF(A6:A14, {"*apples*", "*bananas*", "*lemons*"}, B6:B14)))

    I can only seem to get this to work with a SUMIF and not a SUMIFS - when I translate the above formula into its SUMIFS equivalent:

    =SUM(ARRAYFORMULA(SUMIFS(B6:B14, A6:A14, {"*apples*", "*bananas*", "*lemons*"})))

    the formula does not work (it only respects the first criterion "*apples*".

    Am I doing something wrong? Or is there a reason this wouldn't work with SUMIFS?

    Thanks!

  18. Rain says:

    =SUMIFS('p_s MastNum'!$F:$HF,'p_s MastNum'!$B:$B,$D$1,'p_s MastNum'!$C:$C,$F$1,'p_s MastNum'!$E:$E,$B$19,'p_s MastNum'!$F$3:$HF$3,$A20)

    is my formula

    I get a #Value error.

    If I remove the last criteria and use $F:$F as the range, it works. However, I want it to return/add the values in row 1 & 2. It is another filter I need to use.

    In Sheet "p_s MastNum"
    Row 1 & 2 are names
    Row 3 is a helper row joining the two names with a " "
    Col B = Month each row has a value
    Col C = Year each row has a value
    Col E = 1 of 7 headers in each row. There are more than 1 header in the column

    Please help.

    • Hello Rain,

      For me to be able to help you, please share an editable copy of your spreadsheet with us (support@apps4gs.com) with 2 sheets: 1) source data with a formula, 2) the result you expect to get.
      Note. We keep that Google account for file sharing only, please do not email there. Once you share the file, just confirm by replying here.

  19. Kelly says:

    Im trying to do a formula, not sure if the ones above are suitable - essentially I want to have a total that is increased/deducted by whether or not a number in a cell has a yes or no in the cell next to it.

    Basically I have a "bills paid out or to be paid out" section listed and then want to select yes or no next to it to say if its been paid yet or not which will then auto update the "whats left to pay out this month". so cell A1 - Car Insurance B1 - £153 C1 Yes - by changing it to yes, it doesnt calculate this in total for the month, it excludes it. but if it said no, it will include it in the total left to go out?

    Hope this makes sense!

  20. Roger says:

    Hi,
    I have check boxes in column D rows 32-160, Numbers in column E rows 32-160, and a drop down box with numbers in column I rows 32-160.
    In G19 I'm trying to enter a formula that will give me the number in each row of E multiplied by the number in corresponding row of I, if the check box in column D is checked. Then divide the resulting number by 16.
    Below is the formula that I have been playing with.
    =sumif(D32:D160, true, (E32*I32)/16:(E160*I160)/16)

    Thanks in advance,

      • Roger says:

        Hi Natalia,
        I tried your formula but am still having issues.
        I see what your formula does. I think I missed one thing. I want the total of my results to be in G19.

        I get the following error message:
        Array result was not expanded because it would overwrite data in G20.

        • Hi Roger,

          The thing is that ArrayFormula processes the entire column and returns the result for each row at once. The contents of G20 (and below) doesn't allow the formula to return the outcome. Once you clear those cells, you will see the results. Try pasting the formula to an empty column – you'll see what the formula returns exactly.

          If you need the total of those, just wrap the formula in SUM:
          =SUM(ArrayFormula(IF($D$32:$D$160=TRUE,$E$32:$E$160*$I$32:$I$160,"")))

  21. Rajveersingh says:

    i would like to add like this
    A B
    2 8
    5
    7
    6
    8
    10
    14
    15
    17
    12
    14
    i want to add top values with respect to cell reference B.if it is between 5-9 than add top 5 values in A, if B is between 11-15 than add top 10 values in A. Please help me.

  22. Fatos says:

    Hi there
    I am struggling with a formula, and hope you can help me to corect it.
    SUMIFS(K2:K46;F2:F46;Q2; OM(SUM(N2:N46)>0))
    I am need the formula to add all values in column K, for the names in column F which equals to the cell Q2 ----
    But only if at the same time all the related values in row N are >0 (with related values do I mean the rows with the same name as in Q2)....
    tried it with many alternatives, but did not succed, therefore did I try to summ up the values... And now do totaly give up and beg for your support

    Thanks a lot
    Fatos

    • Fatos says:

      I am happy with the first part of the equation (to summ/add up values in cloumn K if the text in column F = text in cell Q2
      but I really do not know how to combine, or even have a seperate equation for the second part, also same condition for text column F (=text in cell Q2) applies here for the range of rows in column N, but only if the value in those do not contain 0 aka are >0.

      Looking forward to hear a solution
      Thank you

        • Fatos says:

          Hi Natalia,

          Thank you! In the past couple of days I came also to the same formula, but unfortunately it gives me not the result I need. So my fault, I formulated wrongly. I was not very clear I am afraid. I want the formula to calculate the total, or give me a 'yes' if both equations are ok
          also F2:F46=Q2
          AND All (the related) rows in column N are >0
          So a 'yes' if both equations are met, a 'no' if there is even a single "0" in the rows of column N (but only for the rows there first part of equation (F2:F46;Q2)

          So sorry, I am trying now for over a week, and can simply not find the solution.
          Like written before, it is even ok if I need the 'split' the formula in 2-3 parts and do first one part in a cell, then another etc.... to reach the result

          Have a great day!

          • Hi Fatos,

            Would you mind sharing a small sample spreadsheet with us (support@apps4gs.com) with 2 sheets: a sample of your data and the result you expect to get? I kindly ask you to shorten the tables to 10-20 rows. If you have confidential information there, you can replace it with some irrelevant data, just keep the format.

            Note. We keep that Google account for file sharing only and don't monitor its Inbox. Please do not email there. Once you share the file, just confirm by replying here. I'll look into it and do my best to help.

  23. Dante says:

    Month Job Hrs
    20-Mar 40 10
    20-Mar 60 12
    20-Mar 10 5
    20-Mar 15
    20-Apr 50 12
    21-Apr 45 8
    22-Apr 10

    20-Mar 20-Apr
    No. of Job
    No. of Hr I need a formula that will sum values from column C with the following criteria
    1. sum all hours for particular month with values in column B

    • Hello Dante,

      Assuming the table covers 10 rows, here's the formula to sum all numbers for March:
      =ArrayFormula(SUMIFS(C2:C10,MONTH($A$2:$A$10),3,B2:B10,"<>"&""))

      You just need to adjust the ranges (to your number of rows) and change that number 3 that stands for March to a number of your month of interest.

  24. florian Ughetto says:

    Hello! I love your content and I'm almost there with my formula :X but almost means still not.
    How to use those IF to create a formula like this.

    I have A, B, C.. columns
    I would like to make specific operation 'plus' or 'minus' bases on a cell indication.

    ANy idea?

  25. wouter says:

    Help.

    It's just not working with the SUMIFS
    I've got this:
    =sumifs(uren!$E$4:$E ; uren!$A$4:$A ; C2 ; uren!$D$4:$D ; $A3 )

    uren!$E$4:$E = referring to other tab, the sum up the hours
    uren!$A$4:$A ; C2 = saying search for c2 this range on the other tab
    uren!$D$4:$D ; $A3 = saying search for c2 this range on the other tab

    What do I not see???? I checked for so many times. And the cells seem to be correct.
    It doesn't give an error, but keeps giving me a 0

  26. David htz says:

    Hi Natalia and thank you for these helpful tutorials.
    I would like to compare two text columns (on seperate sheets) lets say column A:A on sheet1 with column J:J on sheet 2. I also have a column B:B on sheet 1 with numbers. So when there is a match between Sheet1!A:A and Sheet2!J:J i would like to calculate the sum of the B:B correspondant on sheet1 . I hope it's clear ^^
    Can you help me please ?

  27. Anonymous says:

    I'm having trouble finding a way to sum the exact same cells across 100+ worksheets. In this case, I'd have the worksheets all named something similar for the first part of the string (i.e "Submissions_From_Field_"Initials) while Initials will vary for each submitter. Is there a way to concatenate the worksheet name so that all of these can be included when I sum B3 across all worksheets and then won't have to type and open 100+ worksheets to get sum across all?

  28. Not Online says:

    Hello,

    I received a formula from someone else, but I need to modify it by 1 cell.

    Original formula (works perfectly, but I'm unable to modify it myself):
    =SUM(ArrayFormula(if(mod(sequence(1,COLUMNS(E6:6)),6)=1,E6:6)))

    This formula was set up to SUM every 6th column, row 6 beginning from E6, but I need to modify it to begin at F6 instead. Simply changing the formula from "E6:6" to "F6:6" returns the "#ERROR!" sign and I can't figure this out.

    I'd like to SUM F6, L6, R6, X6, AD6, etc. (Every 6th column). Plus I'll be routinely adding and deleting columns by groups of 6.

    Columns A-C are permanent and are never deleted or added to.
    Ex. Deleting columns D-I, which would delete F6
    Ex. Adding columns AB-AG which would add AD6

    This formula worked perfectly for beginning at E6, but I cannot seem to simply change it to F6 as I'm met with "#ERROR!". What am I not understanding that makes it so "E6:6" cannot simply be replaced with "F6:6"?

    Any help is much appreciated and I can't thank you enough!

  29. Alan Williamson says:

    Thank you ... this article was a life-saver and really helped bring my GSheet to life.
    Appreciate the effort to educate others.

  30. JR says:

    Looking for help with this:
    IF SUM(H60,H75)>86.66, 43.33-SUM(H60,H75), 0)
    • where H60 to H75 are a row of decimal values that shouldn't exceed 86.66
    • if they exceed 43.33 the amount should be reduced by the difference (86.66-SUM(H60,H75))
    For some reason this formula doesn't work. Is it syntax?

    • Hello Matt,

      we have a tutorial on the basics of drop-downs in Google Sheets here. You may gain some ideas for your task there.

      We could also try and help you out, but for that, I have to ask you to share your sample spreadsheet with us (support@4-bits.com) with your example data and the result you expect to get. Once you share the file, just confirm by replying here. Thank you.

  31. Matt says:

    I have a Google sheets workbook that utilizes a cover sheet which picks up data from subsequent sheets within the book. On the cover sheet I want to add a drop-down menu that will change the data values depending on the item listen from the drop-down list.

    For example I want to see sales revenue data by country. Let's call it US, China, and Singapore. Within each sheet is a formula pulling in data for a hardcoded country, such as "US". I want to make this dynamic and changed based on the drop-down menu selection made. So if China is picked the SUMIFS will start looking for China.

    Thoughts?

  32. Taieuro says:

    Dear ablebits.com Team,
    How to use sumifs () function between multiple Google sheet files ?!
    I want a file just to display the results from the data of other files!
    For example: File A will use SUMIFS functions to add data from files B, C, D ...
    Please help me!

  33. Carmen says:

    Thanks for this great explanation!
    I think this is close to what I need; however, I'm having trouble with a nested quantity.
    I have 3 sheets: Responses (Static Data), List (Static Data), Compiled (Static with Dynamic Values/formulas)
    All columns are ranges with the respective names.
    Responses (Static) contains the following "columns/ranges": RespDate, RespItem, RespQty
    All Responses data could be duplicate entries.
    List (Static) contains: ListItem, ListWeight
    All ListItem entries are unique
    Compiled (Static with Dynamic) contains: CompDate (Static), CompWeightTotal (Dynamic)
    All CompDate entries are unique
    I want to display the total weight of all items (CompWeightTotal) for each specific date (CompDate) in the Compiled Sheet.
    Step 1: Get the Sum of RespQty of each specific item for that specific date.
    Step 2: Multiply the sum of the Qty for that item for that specific date by the ListWeight.
    Step 3: Get the Sum of all weights for that specific date.

    I have part of Step 1; however, it is a general sum of RespQty: SUMIF(RespDate,A2,RespQty) where "A2" is a date. If 2 entries exist for this date and each entry had RespQty of 2, the returned value is 4.
    I need to figure out how to count the quantities of a specific item and then multiply this sum to the weight of the specific item found in "List".

    Maybe I should be using an array formula?

  34. mikecu says:

    Has google changed the way SUMIF works? Sheets now says the order of operators is (Range,Criteria,CriteriaRange) which is different from what's described here, and Sheets also says that it can only take three operators, so it won't accept a Criteria2 and CriteriaRange2.

  35. Robert Irwin says:

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

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

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

  36. Harley Dela Cruz says:

    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.

  37. Carlos says:

    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.

  38. Ravinder says:

    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.

  39. Luc says:

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

  40. Faris Shahin says:

    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.

  41. Virginia says:

    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.

  42. Lara says:

    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.

  43. Joana says:

    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!

  44. Cleomir says:

    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))

  45. Irina says:

    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 ?

    • Mary says:

      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.

  46. charlene says:

    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

    • Doug says:

      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/2018/03/15/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.

  47. SheRichTX says:

    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.

  48. Biswadeep says:

    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

    • Peter G says:

      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)

  49. Enamel Caruana says:

    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

  50. AbdulAziz Kapande says:

    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 :)