Understand Filtering in
Tableau
Unit 2 Lesson 2.3
Introduction
• Filters are used to reduce the quantity of large data to gain insights
into more specific items. For example: Reducing world wide sales to
just the sales for Ireland.
• It does not change your raw data just want is in the view.
Filter Types in Tableau
• The following are the filter types in Tableau;
• Extract Filters
• Data Source Filters
• Context Filters
• Dimension Filters
• Measure Filters
• Date Filters
• Table Calculation Filters
• In the unit on filtering your data, we will learn more about measure,
dimension and date filters.
Extract Filters
• When you connect to data, you can
choose live or extract. Extracts are a
snapshot in time and reduces the
number of times Tableau queries the
data source.
• As part of this process, you can filter
out data that isn't relevant to your
analysis. For years of data you only
want the last years – you can filter
out the rest.
Data Source Filters
• Data source filters reduce the amount of data
being fed into Tableau and restrict what data the
viewer sees.
• With certain access rights, the viewer can view all
of the underlying data in a data source. Filter a data source to keep or
remove fields.
• If sensitive data hasn't been excluded from the
data source, use data source filters to filter it out.
• For systems that rely heavily on partitions or
indexing, data source filters may yield tremendous
control over the performance of queries issued by
Tableau.
Context Filters
• All filters are computed independently
• Context filter – when you want to have
a certain order
• Example: you have two dimension
filters, one on Region and the other on
top 10 on products, both filters will
apply to the entire data set. If you want
to see the top 10 products in each
region, set the Region filter as the
context filter.
Dimension Filters
• Dimensions contain discrete
categorical data
• Filtering this type of field means
selecting the values to include or
exclude.
• For example, use a dimension filter to
show products that have low sales in
specific regions.
Measure Filters
• Measures contain quantitative data
• Filtering this type of field means selecting
a range of values that you want to
include.
• For example, show only products that
have sales greater than 10,000.
• A measure filter allows you to select a
range of values
Date Filters
• Date filters allow you to filter data by a
range of dates, relative dates, or exact
dates.
• For example, show products that have
been ordered starting January 2017.
Table Calculation Filters
• These filters are applied after the view has
been produced.
• Table Calculation Filters are used when you
want to filter the view without filtering the
underlying data.
Filtering Order of Operations
• Order of Operations –
where tflters get
applied in Tableau in a
certain order
• Tableau executes filters
in the order displayed
on the diagram to the
right.
Context Filters - Introduction
• By default, filters that you set in Tableau are computed independently
- each filter accesses all rows in your data source without regard to
other filters.
• You can set one or more categorical filters as context filters for the
view. We will look at this in the following slides.
• A context filter is an independent filter. Any other filters that you set
are defined as dependent filters because they process only the data
that passes through the context filter.
Context Filters Scenario
• Your grocery shops contain lots of products. You want to find the top fruit
and vegetables by profitability for all your grocery shops.
• Your task is to find the top 10 breakfast products by profitability for all
stores.
• If the data source is very large, you can set a context filter to include only
fruit and vegetables.
• Then you can create a top 10 filter by profit as a dependent filter, which
would process only the data that passes through the context filter.
Create a Context Filter
• To create a context filter, select Add to
Context from the context menu of an
existing categorical filter. The context is
computed once to generate the view. All
other filters are then computed relative to
the context.
Context filters:
• Appear at the top of the Filters shelf.
• Are identified by a gray color on the Filters shelf.
• Cannot be rearranged on the shelf.
Modifying a Context Filter
You can modify a context filter by:
• Removing the field from the Filters shelf – If other context filters remain on
the shelf, a new context is computed.
• Editing the filter – A new context is computed each time you edit a context
filter.
• Selecting Remove from Context – The filter remains on the shelf as a
standard filter. If other context filters remain on the shelf, a new context is
computed.
•
Speed up Context Filters
To improve performance of context filters, follow these general rules.
• Using a single context filter that significantly reduces the size of the data set rather than
applying many context filters.
• Complete all of your data modeling before creating a context. Changes in the data model,
such as converting dimensions to measures, require recomputing the context.
• Set the necessary filters for the context and create the context before adding fields to
other shelves. Doing this work first makes the queries that are run when you drop fields
on other shelves much faster.
• If you want to set a context filter on a date you can use a continuous date. However,
using date bins like YEAR(date) or context filters on discrete dates are very effective.
Let’s do an exercise – Step 1
• Open Tableau
• Connect to the
sample
superstore data
set
• Drag sales to the
columns and
sales to the rows
Exercise - Step 2
• Create a filter to show the top 10
selling products.
• Drag Sub-Category field to the
Filters shelf
• In the Filter dialog box, switch to
the Top tab and define a filter that
is Top 10 by Sum of Sales.
Sorting your data
• If your data is not sorted in order –
follow these steps
• Hover over sub-category on the
chart and you will see a drop-
down arrow.
• Choose Field and then SUM(Sales)
• Your data should now be in order,
showing the largest sales first
Exercise – Step 3
• Drag category to the filter box and
select furniture.
• Click OK
• Instead of 10 products, you see 3.
• Why?
• By default, all filters are evaluated
separately. Thus, the view shows the
intersection of the results.
• Therefor, this view shows that three of
the top 10 overall products are
furniture products.
Exercise – Step 4
• To find out what the top 10 furniture
products are we need to make the Category
filter a context filter.
• Right-click the field on the Filters shelf and
select Add to Context.
• Notice that the category has now moved
above the sub-category and is shaded grey.
• Note the view updates to show the top four
furniture products. Why not 10?
• Because only four of the sub-categories
contain furniture. But we now know that
the Top 10 filter is being evaluated on the
results of that context. Furnishings was not
in the original Top 10 for all categories.
Exercise – Step 5
• On the category filter select Show filter
• On the filter (right of your Tableau
worksheet) select the drop-down
arrow.
• Then select Single Value (list)
• You can then select categories or just
one of the three individual ones.
Additional Resources
• For more information you can click on this YouTube video – it is an
hour long and shows Tableau’s order of operations.
• https://www.youtube.com/watch?v=fyDY0_Ivy54