# Filtering data

Filtering data

After adjusting the look and feel of a visualisation, you may want to consider adding interactive elements to your visualisation, including adding filters. Filtering is a method of reducing as well as analysing data.

Filtering can occur:

• at the data source view, to reduce the data you work with

• at the sheet view, for analysis.

Filters help viewers to focus on the information that’s most valuable to them by reducing the amount of data displayed on a visualisation. For example, a filter might allow you to select a state, so you can see the stores from a specific state rather than the entire country.

Let’s look at some ways to filter your visualisations in Tableau.

## Select to keep or exclude data points

You can filter individual data points (also known as marks) or a selection of data points. For example, you can filter a scatter plot to exclude outliers.

To filter marks from the view, select the data you want to keep or exclude.

Keep Only keeps the data you selected and filters out the rest.

Exclude excludes the data you selected and keeps the data that wasn’t selected.

## Select headers to filter data

You can select headers to filter entire rows or columns from your view. These filters are applied to the sheet and apply to the visualisations that are built from it.

## Drag dimensions, measures, or date fields to the filters shelf

You can create a filter by dragging a field from the data pane to the filters shelf. This opens the filters dialogue box, which allows you to make filter selections. The dialogue options are based on the type of data you’re filtering. In this case, we are filtering the data by customer names.

### Filtering dimensions (categorical data)

Filtering categorical data usually involves specifying values to include or exclude. For example, you might filter a country field to display Australia.

When you drag a dimension into the filters shelf, a dialogue box appears to prompt you to specify your filter criteria.

There are four tabs in the dialogue box.

1. General: Specify the values you want to include or exclude.

2. Wildcard: Specify a pattern to filter on. For example, filter an email address field for only ‘@hotmail.com’ domains.

3. Condition: Define rules to filter on. For example, filter Product Price to display products that are equal to or above $100. 4. Top: Define a formula that computes data to filter on. For example, filter on the Top 10 customers by Account$.

## Filtering measures (quantitative data)

Quantitative or numerical data is typically filtered by range. For example, you could filter the Sales field in the CustomerRank sheet to display those with sales between $20,000 and$40,000.

When you drag a measure into the filters shelf, you’ll see this dialogue box.

When you’ve decided how you want to filter the field, click Next.

You’ll be prompted to select from three types of filters:

1. Range of values: Displays the range within min and max values.

2. At least: Displays all values greater than or equal to the value specified.

3. At most: Displays all values less than or equal to the value specified.

## Filtering dates

Dates are typically filtered within a range (e.g. filtering for all sales in a calendar or financial year).

When you drag a date field to the filters shelf, you’ll see this dialogue box.

As with the other filter types, when you click Next, you’ll be prompted to select from several options to specify how you want to filter the date field (e.g. Relative dates, Range of dates, and Discrete dates).

## Displaying interactive filters in the view

When you’ve created a filter, you can add it to the view so you can include or exclude data quickly.

## Are you having difficulty with filters?

If you follow the example and have problems, don’t panic. Ask questions or share and discuss suggestions and solutions with other learners in the Comments section.