Questions tagged [countif]

COUNTIF is an Excel function which allows for the counting of values in a range where the values meet a criterion.

Microsoft describes the syntax so:

COUNTIF(range, criteria)

The COUNTIF function syntax has the following arguments:

Range Required. One or more cells to count, including numbers or names, arrays, or references that contain numbers. Blank and text values are ignored.
Criteria Required. A number, expression, cell reference, or text string that defines which cells will be counted. For example, criteria can be expressed as 32, ">32", B4, "apples", or "32".

Note

o You can use the wildcard characters - the question mark (?) and the asterisk (*) - in criteria. A question mark matches any single character, and an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.

o Criteria are case insensitive; for example, the string "apples" and the string "APPLES" will match the same cells.

COUNTIF has been appreciated for checking whether a value is present in a list of values (Super User).

The COUNTIFS function, introduced with Excel 2007, allows for multiple criteria and ranges within a single function, though more than one COUNTIF may be combined to similar effect.

1796 questions
109
votes
4 answers

Pandas counting and summing specific conditions

Are there single functions in pandas to perform the equivalents of SUMIF, which sums over a specific condition and COUNTIF, which counts values of specific conditions from Excel? I know that there are many multiple step functions that can be used…
user3084006
  • 5,344
  • 11
  • 32
  • 41
43
votes
4 answers

How do I combine COUNTIF with OR

In Google Spreadsheets, I need to use the COUNTIF function on a range with multiple criteria. So in the table below, I would need to have something like =COUNTIF(B:B,"Mammal"or"Bird") and return a value of 4. A |B ------------------- Animal…
17
votes
3 answers

Count number of cells in a range that match the content of a different cell

I am trying to use COUNTIF in Excel to find how many items in a range match the contents of a separate cell. The idea is, the range contains everyone's answers to a given question (a one-word, non-numeric answer); the comparison column contains the…
Gene Barrett
  • 173
  • 1
  • 1
  • 5
16
votes
3 answers

Excel Countif Not equal to string length of zero

I have a formula an iferror formula that puts in "" if an error occurs. This is a zero length string. I'd like to do a count if not equal to "". =countif(A:A,<>"") 'is not a valid formulas =countif(A:A,"<>") 'checks for actual blanks, not zero…
user2242044
  • 8,803
  • 25
  • 97
  • 164
15
votes
4 answers

std::map, count values that are true

I have a map: std::map all_triggers_didfire; I fill it and in the end would like to obtain the number of values that are true. The following code works: int count_did_fire = std::count_if( all_triggers_didfire.begin(), …
fuenfundachtzig
  • 7,952
  • 13
  • 62
  • 87
12
votes
1 answer

Google Sheets COUNTIF / COUNTIFS formulas based on multiple criteria

I'm looking for some expertise with formulas. I've got a raw data source and need to be able to summarise it in a separate sheet based on a number of different variables of both number and text formats. I've tried some COUNTIFS, INDEX and other…
norburm
  • 121
  • 1
  • 1
  • 3
12
votes
5 answers

Count number of occurrences based on 2 conditions or Regexp

How can I get the number of occurrences for some range based on A regular expression 2+ conditions; let's say cells that contain "yes" and / or "no" What I've got for the moment: COUNTIF(B5:O5; "*yes*") I tried to use COUNTIF(B5:O5; {"*yes*",…
NGix
  • 2,542
  • 8
  • 28
  • 39
12
votes
1 answer

Count occurrences of values

I have a column of text values with repeated values. I want to create a new column of unique values (no repeats) and a column with the frequency of each of those values. What's the easiest way to do that? Efficiency isn't much of a concern as it's…
sagacious
  • 129
  • 1
  • 1
  • 3
11
votes
3 answers

Excel Countif Date in column A is greater than column B

Columns A and B both have dates. If the date in column A is greater than the date in the same row of column B, the row should be counted. To add context, I am trying to count the number of rows where the completion date is past the due date. How…
spassen
  • 1,550
  • 8
  • 20
  • 32
10
votes
1 answer

How to add calculated column to Dataframe counting frequency in column in pandas

I have dataframe like this: county 1 N 2 N 3 C 4 N 5 S 6 N 7 N and what I'd like to reach is: county frequency 1 N 5 2 N 5 3 C 1 4 N 5 5 S 1 6 N 5 7 N 5 Is…
data_b77
  • 415
  • 6
  • 19
10
votes
3 answers

Excel array countif formula

I want to use COUNTIF function to evaluate how many items out of 2,0,0,5 are greater than 2? In Countif function, first argument is range and second is criteria. I have tried the below formula. Even tried using Ctrl+Shift+Enter at the end to…
Surbhi Manocha
  • 155
  • 1
  • 4
  • 15
8
votes
7 answers

COUNTIF can't count non-blank formula results?

I am looking for a criterion to use in =countif(range_of_formulas, [criterion]) that will identify non-blank results of formulas. I've found quite a few of those, like "<>" , "<>"&"" , "<>""" , ">""" , "*" and more (e.g. on SO here and here). But…
eli-k
  • 10,898
  • 11
  • 40
  • 44
6
votes
2 answers

How to use variable range in Google Sheets?

Currently I have such formula: COUNTIFS(B3:B36,"16",E3:E36,"01") Would it be possible to turn these ranges B3:B36 and E3:E36 into variables, like B'start_cell_value':B'stop_cell_value'. The whole thing would look like: …
6
votes
2 answers

iterate row by row COUNTIF using ArrayFormula on Google Sheets

I am trying to iterate a COUNTIF formula that counts the number of cells in each row containing numbers greater than 4. I am trying to use ArrayFormula to do this but it isn't working. Unfortunately it counts ALL the cells matching the condition…
herteladrian
  • 381
  • 1
  • 6
  • 18
6
votes
3 answers

How to do countIf() in Oracle

How do I select a variable which gives an output the same as the excel function: COUNTIFS(A1:D1,"<25", A1:D1, ">16")? I.e. to count the number of times the values in my four fields are between 16 and 25.
amsbam1
  • 109
  • 1
  • 4
  • 10
1
2 3
99 100