Count all observations

=COUNTA(data)

Count observations that meet a condition

=COUNTIF(data,condition)

Entering conditions

Conditions, including numerical ones, must be entered as strings. To count all observations less than some value $k$:

=COUNTIF(data,"<k")

or to count all observations greater than or equal to some value $k$:

=COUNTIF(data,">=k")

Demo

Counting within categories

If you have data that are grouped into categories (e.g. zipcodes, countries, etc.) you can count the frequency of an outcome for each category like this:

=COUNTIFS(categories, a category, values, condition)

The first argument takes all the categories and chooses which category based on the second argument. The third argument takes all the values and then counts how many of them meet the fourth argument.

For instance, suppose you have the following data:

Category Values
B 6
B 20
A 4
B 18
A 5
B 12
A 11

To count total number of values that are at least as big as 10, you would run

=COUNTIF(Values,"<10")

but to find the total number of values within category “A” that are at least as big as 10, you would instead run

=COUNTIFS(Category, "A", Values, ">=10")

Demo