Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set multiple criterias for a Google Spreadsheet SumIF formula?

I want a formula which sums column D if column K has a value between 3000 and 4000. I've tried the following but none work:

=SUMIF(K3:K67; ">= 3000 & < 4000";D3:D67)
=SUMIF(K3:K67; ">= 3000 " & " < 4000";D3:D67)
=SUMIF(K3:K67; ">= 3000 AND < 4000";D3:D67)

Is this possible or must I use the ArrayFormula function (which I don't understand) like in this question?

Edit: This works, so there's nothing wrong with the data:

=SUMIF(K3:K67; ">= 3000";D3:D67)
like image 494
Nilzor Avatar asked Apr 22 '13 11:04

Nilzor


2 Answers

Edit: Google Sheets now supports SUMIFS.

Original answer: There are a number of ways to do this. A little while ago I spent some time working out which method is the most watertight (for example, I am guessing the formula in the original post of the question you linked may have failed because there were probably text entries - perhaps a header - in the column to be summed).

IMO this is the most watertight general solution for a multi-conditional sum in Google Sheets:

=SUM(IFERROR(FILTER(sum_range;condition_1;condition_2;...)))

so in your specific case:

=SUM(IFERROR(FILTER(D3:D67;K3:K67>=3000;K3:K67<4000)))

Although the same can be achieved with the following:

=SUMIF(K3:K67;"<4000";D3:D67)-SUMIF(K3:K67;"<3000";D3:D67)

but I guess these "in-between" conditions are a special case where you can do this; the first solution is perhaps a better general solution.

like image 77
AdamL Avatar answered Sep 27 '22 16:09

AdamL


The answer of this question is deprecated since SUMIFS is now included, adding support to multiple criterias to SUMIF.

like image 28
wikier Avatar answered Sep 27 '22 16:09

wikier