Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Spreadsheet COUNTIF formula equivalent with two criteria

I have a Google Docs spreadsheet with a few columns. In column D I have values Man OR Woman. In column G I have values Yes OR No. What I would like to to do is to count how many times MAN will answer with YES. So there are two criterias 1.Man and 2.Yes

I have this formula which only counts values in cells D2 and G2. I would like to count values from D2 to D500 and from G2 to G500.

=IF(AND('Revision: 2'!D2="Man",'Revision: 2'!G2="Yes"),1,0)

How I can do that?

Thank you!

like image 232
Boco Avatar asked Apr 26 '12 17:04

Boco


People also ask

How do I use Countif with two criteria in Google Sheets?

The COUNTIFS() function in Google Sheets can be used to count the number of rows in a spreadsheet that meet multiple criteria. This function uses the following syntax: COUNTIFS(criteria_range1, criterion1, criteria_range2, criterion2, …)

Can you use Countif with two criteria?

The Excel formula to countif multiple criteria[1] is =countifs(). The “s” on the end makes it plural and therefore implies that there are multiple criteria (2 or more). In the examples and illustrations below in this tutorial will show you exactly how to use COUNTIFS in Excel.

Can you add two Countifs in Google Sheets?

In Google Sheets, you can't use the formula as above. Multiple criteria in Countifs in the same column is not possible or recommended in Google Sheets. Actually, it's not correct. We can include multiple conditions from the same column (OR criteria in the same column) and also from a different column in Countifs.

Can you use Countif for 3 criteria?

#3 Count Cells with Multiple Criteria – Between Two DatesTo get a count of values between two values, we need to use multiple criteria in the COUNTIF function. We can do this using two methods – One single COUNTIFS function or two COUNTIF functions.


2 Answers

Google spreadsheet does not support COUNTIFS function ... however following is one of several formulas you can use for what you want to do ...

=ArrayFormula( SUM( ( D2:D500 = "Man" ) * ( G2:G500 = "Yes" ) ) )
like image 108
Alex Gordon Avatar answered Oct 19 '22 03:10

Alex Gordon


In the new version of Google Spreadsheets COUNTIFS is already built in. You can use it for multiple criteria.

Sample Usage:

COUNTIFS(A1:A10, ">20", B1:B10, "<30")
COUNTIFS(A7:A24, ">6", B7:B24, "<"&DATE(1969,7,20))
COUNTIFS(B8:B27, ">" & B12, C8:C27, "<" & C13, D8:D27, “<>10”)
like image 39
xxxbence Avatar answered Oct 19 '22 05:10

xxxbence