Difference between revisions of "Manuals/calci/COUNTIF"

From ZCubes Wiki
Jump to navigation Jump to search
Line 60: Line 60:
 
=COUNTIF(B2:B7, ">8")  : Counts the number of cells  in the range B2 to B7 containing number of objects greater than '8', ''returns 3'' as a result.
 
=COUNTIF(B2:B7, ">8")  : Counts the number of cells  in the range B2 to B7 containing number of objects greater than '8', ''returns 3'' as a result.
  
=COUNTIF((B1:B5),"A",11)  : Counts the number of cells that contain numbers in the cells B1 to B5 , text value "A" and number '11', ''returns 4'' as a result.
+
=COUNTIF(A2:A6,A4)  : Counts the number of cells in the range A2 to A6, that has text similar to A4, ''returns 1'' as a result.
 
</div>
 
</div>

Revision as of 12:45, 4 November 2013

COUNTIF(r, c)

  • Where 'r' is the range of cells.
  • 'c' is the criteria in the form of a number, expression, cell reference, or text.
  • COUNTIF() function calculates the number of cells that satisfy a given criteria.

Description

COUNTIF(r, c)

For example, COUNTIF(A1:A8,"JOHN") returns the number of cells in the range A1 through A8 that match with the text "JOHN".

  • Criteria containing numbers can be expressed as 66, "66","<=66", ">=66", "<>66" etc.
  • Criteria with text values can be expressed in quotes as "Red" etc.
  • Combination of functions can also be used as COUNTIF(A1:A3,"Red")+COUNTIF(A4:A7,"Orange") etc.
  • Special characters such as '*', '?', '~' can be used in the criteria field to match a certain sequence of characters.
  • COUNT() can be used to count the number of cells in the given range except logical values, error values and text.
  • COUNTA() can be used to count the number of non-empty cells that may be numbers, number representation of a text, error or logic values, dates etc.

Examples

Consider the following table which shows the color of object in first column and respective count in the second column. COUNTIF() can be used to count the number of cells that match a given criteria within a mentioned range of values.

PURPLE 8
RED 6
BLUE 20
GREEN 23
RED 1
ORANGE 10
BROWN 2

=COUNTIF(A1:A7,"RED") : Counts the number of cells in the range A1 to A7 that has text "RED", returns 2 as a result.

=COUNTIF(B2:B7, ">8") : Counts the number of cells in the range B2 to B7 containing number of objects greater than '8', returns 3 as a result.

=COUNTIF(A2:A6,A4) : Counts the number of cells in the range A2 to A6, that has text similar to A4, returns 1 as a result.