Numbers Exercises

FILTER in Numbers: Keep Only the Rows You Need

Last updated:

Short answer: FILTER(array, test, if-empty) keeps only the rows where the test is TRUE. For example =SUM(FILTER(B2:B5,C2:C5>2)) adds the prices of products with a quantity above 2.

The examples use this table.

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

Filter with one condition

The first argument is what you want back, the second is a test with the same number of rows. Only the rows where the test is TRUE survive. Here we keep the prices where the quantity is more than 2, and add them up.

=SUM(FILTER(B2:B5,C2:C5>2))
Result: 18

Count the rows that remain

Combine FILTER with ROWS to count how many rows match. Three products cost more than 5.

=ROWS(FILTER(A2:A5,B2:B5>5))
Result: 3

Show a message when nothing matches

If no row passes the test, FILTER gives an error. The third argument lets you give a friendly answer instead.

=FILTER(A2:A5,B2:B5>100,"None")
Result: None

Take or drop a number of rows

TAKE keeps the first rows and DROP removes them. The first two prices add up to 10, and the rest to 20.

=SUM(TAKE(B2:B5,2))
Result: 10
=SUM(DROP(B2:B5,2))
Result: 20

Pick columns

CHOOSECOLS selects specific columns from a range. Columns 2 and 3 of the table hold the prices and the quantities.

=SUM(CHOOSECOLS(A2:C5,2,3))
Result: 50

Frequently asked questions

How do I filter data with a formula in Numbers?

Use FILTER, for example =FILTER(A2:A5,B2:B5>5), which returns the products with a price above 5.

What does the third argument of FILTER do?

It sets what to show when no row matches, for example the text "None".

Can I filter on more than one condition?

Yes. Multiply the tests, for example =FILTER(A2:A5,(B2:B5>5)*(C2:C5>2)), to require both to be true.

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