Filtering Data

You may not always want to see all the data in a table. Perhaps you want to see only rows with a specific value in column A, or a higher-than-some-threshold value in column B, or a checkmark in column F. Numbers provides quick filtering for rows through a table’s Column menus, which I describe in Quick Filters. More sophisticated options, such as multiple criteria for filters, are described in Filtering with the Inspector.

Because this chapter is divided between the use of Filter menus and that of the Sort & Filter Inspector for filtering, I’ll mention here two quick items that are common to filtered tables in general:

Quick Filters

When you want a quick look at a subset of the data in your rows, a “quick filter” is your best friend. You can apply a quick filter instantly by selecting from a Column menu, specifying which values you want to remain visible.

Creating Quick Filters

You can do quick filtering whether the table is active or selected:

**Figure 83:** Left: The full table. Center: The Filter Table submenu. Right: The filtered table shows only the 2’s in the first column, but the sum and average footer cells don’t change.
Figure 83: Left: The full table. Center: The Filter Table submenu. Right: The filtered table shows only the 2’s in the first column, but the sum and average footer cells don’t change.

Quick Filter Quick Points

Here are some small but important points you should know before we move on to the slightly more complex procedure of creating filter rules:

Because quick filters interact with settings in the Filter pane of the Sort & Filter Inspector:

Filtering with the Inspector

While Column menus offer a quick solution for simple filtering, it’s the Sort & Filter Inspector’s Filter pane that does the heavy lifting, letting you create multiple rules to filter a column.

A filter rule is a description like Score is greater than 30 or Name contains “Smith” or even Date is in the next 30 days. This flexibility alone puts filter rules in a different league from quick filters.

A filter is made up of one or more rules. (The fact that a single rule can define a filter muddies the water a bit when it comes to understanding the difference between the two, but you’ll quickly become comfortable with the concepts when you work with them.) You can filter multiple columns, resulting in quite sophisticated data selection for a table. When you want to display all your data again, you can turn your filters off (as a set), preserving the setup for reuse.

Filter Rule Benefits

Rules offer many advantages over quick filters. You can:

Create a Filter

Add a Filter

Start with a filter that finds the higher scores among the data:

  1. Select or activate the table, click the Sort & Filter button, and click Filter to open the Filter pane.
  2. Click Add a Filter and choose a column name from its menu. (If there are no column headers, the menu lists Column A, Column B, and so on.) Choose Score for this example.

    Numbers adds a Filters section to the pane; its checkbox is currently unchecked, since there’s as yet no filter applied to the table. A segment for the column you’re filtering—Score, in this example—is also added, and a popover opens from the filter’s Add a Rule button.

  3. Choose a category in the popover and then select a specific rule: click Numbers at the top of the popover and then click Greater Than or Equal To.
  4. Enter additional information to complete the rule: type 35 in the field, and press Return to enter it.

Numbers selects the Filters checkbox and applies the filter; the table displays rows with scores of 35 and over (Figure 85).

**Figure 85:** Left to right: The Add a Filter menu listing all the column headers, the Add a Rule popover, and the rule for the Score filter.
Figure 85: Left to right: The Add a Filter menu listing all the column headers, the Add a Rule popover, and the rule for the Score filter.

To turn off all filters for a table but keep the rules for quick re-use, uncheck the Filters checkbox (shown in the figure above, top right).

Add a Second Rule to a Filter

You can create more than one rule to define a column’s filter, so you can filter for more than one thing in a column: grades A, A- or A+, for instance, or, in our example, the outlying scores of 35 and over or 25 and under).

With the table selected and the Filter pane showing, add a second rule:

  1. Click the Or button beneath the existing rule.
  2. Define the second rule: choose Less Than or Equal To from the popover, type 25 in the field, and press Return.

The rows that are left show only the high and low scores, because, as the Filter pane pretty much spells out in its menus and fields, this filter is: Match any of the following rules: the Score is greater than or equal to 35; the Score is less than or equal to 25.

Delete and Edit Rules

You can modify a filter by deleting or editing any of its rules in the Sort & Filter Inspector’s Filter pane.

To delete a rule, hover your pointer toward the top of the rule in the Filter pane and then click the trash button that appears. To edit a rule, click any of its criteria and make the change—greater than to greater than or equal to, for instance, or the number that you input for that threshold.

If you worked in your sample table following the instructions starting at Add a Filter, you have two rules that together find outlying scores that are 35 and over or 25 and under. To change the current filter to find just the above-average scores:

  1. Delete the second rule (Less Than or Equal To 25) by clicking its trash button (Figure 86).
    **Figure 86:** Deleting a rule.
    Figure 86: Deleting a rule.
  2. Click the Greater Than or Equal To button in the rule that’s left, and select Above Average from the popover’s Number list to replace it; note its subtitle is “in the column,” just to keep you oriented.
Add a Second Filter

First let me reiterate the terminology: a rule is a description of what you want to remain in the column—numbers higher than 10, or cells that contain the word red, and so on. A filter is one or more rules that define what will show in a specific column. So, there’s only one filter for any column, but the filter may have multiple rules.

You can apply multiple filters to a table by creating them for more than one column. As a result, you can find, for instance, all the members of the Blue team (that’s one column) who had above-average scores (that’s another column).

To add a second filter to a table, work in the Filter pane:

  1. Click the Add a Filter button, and choose a column from the menu; in your example file, choose Team.

    Numbers adds another rule segment at the bottom of the Filter pane and opens a popover from that rule’s Add a Rule button.

  2. Pick a rule from the popover: click the popover’s Text button, and choose is from the list. This puts text is in the Team filter segment.
  3. Provide details for the rule: type blue in the field beneath text is (Figure 87), and press Return to enter it.
**Figure 87:** These two filters work together to find the above-average scores for Blue team members.
Figure 87: These two filters work together to find the above-average scores for Blue team members.
All Filters vs. Any Filters

Throughout this chapter, we’ve stuck with the Filter Pane’s default setting of All Filters (it’s in the pop-up menu beneath the Show Rows that Match label), but its alternative, Any Filter, is an extremely useful option.

With All Filters chosen, the filters you’ve defined for your columns are all applied. Say you have a list of student grades, with a column each for the midterm and final exams. If you set up a filter for an A in the Midterm column, and another for an A in the Final column, the All Filters setting means you’ll find only those students who earned A’s in both the midterm and the final. Choose Any Filters instead, and you’ll get a list of the students who scored an A in either the midterm or the final. (That would also include, of course, those who earned A’s in both.)