Numbers Exercises

COUNTIF and SUMIF in Numbers: Count with a Condition

Last updated:

Short answer: COUNTIF counts how many cells meet a condition and SUMIF adds up the values of those cells. The condition goes between quotation marks, such as ">5".

The examples use this table.

Table 1
ABC
1ProductPriceQty
2Apple410
3Pear65
4Kiwi122
5Grape83

COUNTIF: counting cells

COUNTIF counts the cells in a range that meet one condition. Here: how many prices are higher than 5.

=COUNTIF(B2:B5,">5")
Result: 3

SUMIF: adding with a condition

SUMIF tests one range and adds up the values of another range. Here: the quantities of products with a price higher than 5.

=SUMIF(B2:B5,">5",C2:C5)
Result: 10

Several conditions: COUNTIFS

COUNTIFS counts the rows for which several conditions are true at the same time. You give a range and a condition for each.

=COUNTIFS(B2:B5,">5",C2:C5,"<5")
Result: 2

An average with a condition

AVERAGEIF returns the average of only the cells that meet a condition.

=AVERAGEIF(B2:B5,">5",C2:C5)
Result: 3.3333

Frequently asked questions

What is the difference between COUNTIF and SUMIF?

COUNTIF counts how many cells match. SUMIF adds up the values of those cells.

How do I write a condition like “greater than 5”?

Put the comparison between quotation marks: ">5".

Can I count text?

Yes, for example COUNTIF(A2:A5, "Kiwi") counts the cells with exactly that text.

Functions in this article

Practise it yourself

Type the formula yourself in a real exercise and see right away if your answer is correct. The first exercises are free.

Start practising