11  Analysing Data, Sorting and Filtering Tableau Data

NoteWhat This Chapter Covers

Controlling what data appears in a view, and in what order, is one of the most fundamental skills in Tableau. Sorting and filtering are the primary tools for focusing the viewer’s attention on the most relevant subset of data and presenting it in the most meaningful sequence. In this chapter, you will learn every sort and filter type available in Tableau: manual sorts, computed sorts, dimension and measure filters, quick filters, context filters, top-N filters, condition filters, and date filters. You will also learn the filter order of operations, the sequence in which Tableau applies filters, and how to avoid common mistakes that produce unexpected results.

flowchart LR
    A[Raw Data] --> B[Extract Filter\napplied first]
    B --> C[Data Source Filter]
    C --> D[Context Filter\nhighest priority in view]
    D --> E[Dimension Filter]
    E --> F[Measure Filter\napplied last]
    F --> G[Final View]
    style A fill:#e3f2fd,stroke:#1976D2
    style D fill:#fff9c4,stroke:#F9A825
    style G fill:#e8f5e9,stroke:#388E3C


11.1 Sorting in Tableau

NoteThe Four Sort Methods

Tableau provides four ways to sort dimension members within a view:

  1. Manual sort, Drag dimension members into a custom order by right-clicking the axis or header.
  2. Alphabetical sort, Sort A–Z or Z–A by the dimension name itself.
  3. Field sort, Sort by the value of a measure (e.g., sort Sub-Category by descending Sales). This is the most commonly used sort in business charts.
  4. Nested sort, Sort within each pane independently when a view has multiple dimensions. Useful in small multiples and grouped views.

The default sort for any dimension is the data source order, typically the order records appear in the underlying table. For business reporting, field sort (by a relevant measure) almost always produces more meaningful charts than data source or alphabetical order.

NoteHow To: Sorting a Bar Chart by Measure Value
  1. Build a horizontal bar chart with Sub-Category on Rows and Sales on Columns.
  2. Method 1, Toolbar button: Click the Sort Descending button on the toolbar (bars icon with downward arrow). Tableau sorts by the measure currently on the primary axis.
  3. Method 2, Axis click: Click the axis label “Sales” at the top of the chart, a small sort icon appears. Click it once for ascending, twice for descending, three times to return to data source order.
  4. Method 3, Right-click pill: Right-click the Sub-Category pill on the Rows shelf and select Sort. In the dialog, choose Field, select Sales, and set the order to Descending.
  5. To sort within nested dimensions (nested sort): click the inner dimension pill and use the sort dialog, ensuring Nested is ticked.

[Insert screenshot of the Sort dialog box showing Field sort on Sales, Descending order, with the Nested option visible]

NoteHow To: Manual Sorting for Custom Orderings

Sometimes the correct order is neither alphabetical nor by measure, for example, sorting months in calendar order (Jan–Dec) or sorting product lines in launch sequence.

  1. Right-click the dimension pill on the shelf and select Sort.
  2. In the Sort dialog, select Manual.
  3. A list of all dimension members appears. Drag them into your preferred order.
  4. Click OK. Tableau preserves this manual order even when the underlying data changes.

[Insert screenshot of the Manual Sort dialog with month names being reordered by dragging]

TipSorting Tip: Custom Sort Orders Using a Calculated Field

For repeatable, shareable sort orders (especially on Tableau Server), encode the sort order as a number in a calculated field rather than relying on manual sort, which is stored in the view and can break when dimensions change. Create a field like:

Code
# Custom sort order for Ship Mode
CASE [Ship Mode]
  WHEN "Same Day"     THEN 1
  WHEN "First Class"  THEN 2
  WHEN "Second Class" THEN 3
  WHEN "Standard Class" THEN 4
END

Then sort the dimension by this calculated field.


11.2 The Filter Order of Operations

NoteWhy Filter Order Matters

Tableau applies filters in a strict sequence. Understanding this sequence is essential because a filter applied at the wrong level can produce incorrect percentages, totals, and table calculations. The order from first applied to last applied is:

Order Filter Type Scope
1 Extract filter Applied when extracting data; limits what enters the Hyper file
2 Data source filter Applied to all worksheets using that data source
3 Context filter Creates a temporary table; all subsequent filters apply within this context
4 Dimension filter Filters on categorical/discrete fields
5 Measure filter Filters on aggregated measure values (e.g., SUM(Sales) > 1000)
6 Table calculation filter Filters after table calculations are computed (rare; use with caution)

The key practical implication: table calculations are computed before measure filters are applied. If you filter using a measure filter, the table calculation has already been computed on the full dataset, which is usually what you want. But if you need to restrict what the table calculation operates on, you must use a context filter instead.


11.3 Dimension Filters

NoteTypes of Dimension Filter

A dimension filter restricts which members of a categorical field are shown in the view. Drag any dimension field to the Filters shelf to open the filter dialog. Tableau offers four filtering modes for dimensions:

  1. General, Select or deselect specific members from a list. Best for small, stable lists.
  2. Wildcard, Filter members whose names contain, start with, or end with a specified string. Best for large lists or when member names follow a pattern (e.g., all product codes starting with “TBL-”).
  3. Condition, Filter members that satisfy a formula (e.g., only Sub-Categories where SUM([Sales]) > 10000).
  4. Top, Show only the top or bottom N members by a measure. This is the Top-N filter, one of the most useful filter types in business reporting.
NoteHow To: Creating a Top-N Filter with a Parameter

A static top-N filter (e.g., “always show top 5”) is useful but limited. A dynamic top-N filter, where the viewer can choose N, is far more powerful.

  1. Create a parameter named “Top N” with Data Type: Integer, Current Value: 10, Allowable Values: Range (1 to 20).
  2. Show the parameter control: right-click the parameter > Show Parameter Control.
  3. Drag Sub-Category to the Filters shelf. In the filter dialog, go to the Top tab.
  4. Select By field, choose Top, and set the count to the Top N parameter.
  5. Select the measure (Sales) and aggregation (Sum).
  6. Click OK. The view now shows the top N sub-categories, where N is controlled by the viewer via the parameter slider.

[Insert screenshot of the Top filter dialog with the Top N parameter selected, and the parameter control visible on the worksheet]

NoteWildcard Filters for Text Search
Code
# Example wildcard pattern, matches any product containing "Chair"
Contains "Chair"
  1. Drag Product Name to the Filters shelf.
  2. In the filter dialog, select the Wildcard tab.
  3. Enter your search string and choose Contains, Starts with, Ends with, or Exactly matches.
  4. To make the filter interactive on a dashboard: right-click the filter pill > Show Filter. Change the filter control type to Wildcard Match for a live text search box.

[Insert screenshot of a wildcard filter control on a dashboard with “Chair” entered, showing only matching products]


11.4 Measure Filters

NoteFiltering on Aggregated Values

A measure filter restricts the view to records where an aggregated value meets a condition. Because measure filters are applied after aggregation, they answer questions like “show only sub-categories with total sales above $50,000”, not “show only rows where the sales column is above $50,000” (that would be a row-level filter, implemented as a calculated field on the Filters shelf).

Creating a measure filter: 1. Drag Sales (a measure) to the Filters shelf. 2. Tableau prompts you to choose the aggregation level: Sum, Average, Minimum, Maximum, Count, or Standard Deviation. 3. Select Sum and click Next. 4. In the filter dialog, select At least and enter 50000 to show only sub-categories where total sales exceed $50,000. 5. Click OK.

[Insert screenshot of the measure filter dialog showing “At least 50000” for SUM(Sales)]

WarningMeasure Filters and Table Calculations: A Critical Interaction

Because measure filters are applied after table calculations, they can produce surprising results. Consider a “Percent of Total” table calculation on Sales. If you then apply a measure filter to show only sub-categories with Sales > $50,000, the percentages are computed on the full dataset before the filter, so the visible percentages will not add up to 100%.

Solution: Either use a context filter (which recalculates the table calculation on the filtered data) or use a FIXED LOD expression to compute the percentage on the filtered set.


11.5 Context Filters

NoteWhat Is a Context Filter?

A context filter creates a temporary, restricted dataset (a “context”) that all other filters, table calculations, and LOD expressions operate within. It is applied before dimension and measure filters, which means it redefines what “the whole” is for any calculation that references the total.

When to use context filters: - Your Top-N filter is not working correctly because it is selecting the top N from the full dataset, not from a pre-filtered subset (e.g., you want the top 5 sub-categories within the East region, but the dimension filter for East is applied after the Top-N calculation). - Your table calculation percentages are incorrect because measure filters are excluding some members. - You have a very large dataset and want to use a filter to reduce the data volume before Tableau applies expensive computations.

How to add a context filter: Right-click any filter pill in the Filters shelf and select Add to Context. The pill turns grey to indicate context status.

NoteHow To: Fixing a Top-N Filter with Context

Problem: You want the top 5 Sub-Categories by Sales within the East Region, but the Top-N filter is picking the top 5 from all regions.

  1. Drag Region to the Filters shelf and select East only. Click OK.
  2. Drag Sub-Category to the Filters shelf, go to Top > By Field > Top 5 > Sales > Sum. Click OK.
  3. Observe the result, it may show fewer than 5 or the wrong sub-categories because the filters compete.
  4. Fix: Right-click the Region = East filter pill and select Add to Context.
  5. Now the context restricts data to East first, and the Top-N filter correctly selects the top 5 within that context.

[Insert screenshot showing the Filters shelf with the Region filter as a grey context filter pill, and the Sub-Category Top-N filter below it]


11.6 Quick Filters and Dashboard Filter Controls

NoteShowing Filters as Interactive Controls

Any filter on the Filters shelf can be displayed as an interactive control, a dropdown, checkbox list, radio button, or slider, that viewers can operate directly on the worksheet or dashboard.

To show a filter control: Right-click any filter pill on the Filters shelf and select Show Filter.

Filter control types:

Control Type Best For
Single Value (dropdown) One selection from a large list
Single Value (radio buttons) One selection from a small list (< 6 options)
Multiple Values (list) Multiple selections from a categorical list
Multiple Values (dropdown) Multiple selections from a large list
Single Value (slider) A continuous range (dates or numbers)
Wildcard Match Text search across string dimensions
Relative Date Filter by “last N days/weeks/months”

Applying a filter to multiple sheets: Right-click the filter control on the dashboard and select Apply to Worksheets > All Using This Data Source to make the filter global across all sheets in the dashboard.


11.7 Date Filters

NoteFiltering Dates in Tableau

Date filters are among the most commonly used filters in business dashboards. Tableau offers three types of date filter:

1. Relative date filter: Automatically updates relative to today’s date. Examples: “Last 30 days,” “This year,” “Last complete quarter.” Ideal for operational dashboards that should always show the most recent period without manual updates.

2. Date range filter: A fixed range between two specified dates. Useful for ad-hoc analysis or when the analysis period is predetermined.

3. Discrete date filter: Filters on specific date parts (e.g., show only Q1 and Q3, or only January and February). Does not depend on a continuous range.

To create a relative date filter: 1. Drag Order Date to the Filters shelf. 2. Select Relative Dates in the filter dialog. 3. Choose the anchor (today, a specific date, or a parameter-driven date). 4. Set the range: “Last 90 days,” “Last complete month,” or “Year to date.” 5. Click OK. The filter automatically updates every time the workbook is refreshed.

[Insert screenshot of the Relative Date filter dialog with “Last 3 months” selected and the anchor set to today]

TipUsing Parameters for Dynamic Date Ranges

For maximum flexibility, replace fixed date filters with parameter-driven date filters. Create two Date parameters (“Start Date” and “End Date”) and a calculated field:

Code
# Date range filter calculation
[Order Date] >= [Start Date] AND [Order Date] <= [End Date]

Drag this Boolean calculated field to the Filters shelf and set it to True. Viewers can now set any custom date range via the parameter controls.


11.8 Analysing Data: Groups, Sets, and Bins

NoteGroups: Combining Dimension Members

A group combines multiple dimension members into a single category. Groups are useful when your data has granular categories that need to be aggregated for reporting (e.g., combining individual product models into product families, or grouping countries into geographic regions).

Creating a group: 1. Hold Ctrl and click multiple marks or headers in the view to select them. 2. Click the Group icon in the tooltip that appears (paper-clip icon), or right-click and select Group. 3. A new calculated dimension appears in the Data pane with a paperclip icon, containing the group. 4. Double-click the group name to rename it.

[Insert screenshot showing multiple Sub-Category bars selected, the group tooltip icon visible, and the resulting group dimension in the Data pane]

NoteSets: Dynamic and Condition-Based Subsets

A set is a named subset of dimension members that can be defined by a condition, a top-N rule, or manual selection. Unlike groups, which are permanent dimension mappings, sets produce a binary in/out classification that you can use in calculations and colour encodings.

Creating a set: 1. Right-click a dimension in the Data pane and select Create > Set. 2. Choose from three definition methods: - General: Manually select members. - Condition: Define members by a formula (e.g., Sub-Categories where SUM(Sales) > 100,000). - Top: Define as the top N members by a measure. 3. Name the set and click OK. It appears in the Data pane with a Venn diagram icon. 4. Drag the set to the Colour shelf to colour marks as In or Out of the set.

Code
# Set-based calculated field: highlight profit vs. non-profit sub-categories
IF [Top 5 Sub-Categories by Sales] THEN "Top 5"
ELSE "Other"
END
NoteBins: Grouping Continuous Measures

A bin groups a continuous measure into equal-width intervals, effectively creating the data structure behind a histogram.

Creating bins: 1. Right-click a measure in the Data pane (e.g., Sales) and select Create > Bins. 2. Set the bin size (e.g., 500 for $500 intervals). 3. The bin field appears as a discrete dimension with a bin icon. 4. Drag it to the Rows or Columns shelf and drag Number of Records to the opposite shelf to create a histogram. 5. To edit the bin size: right-click the bin field and select Edit.


11.9 Summary

NoteKey Concepts at a Glance
Feature Purpose Key Access Point
Field sort Sort dimension by measure value Right-click pill > Sort > Field
Manual sort Custom ordering Right-click pill > Sort > Manual
Top-N filter Show top/bottom N by measure Filters shelf > Top tab
Context filter Redefine “the whole” for calculations Right-click filter > Add to Context
Measure filter Filter by aggregated value Drag measure to Filters shelf
Relative date filter Auto-updating time window Drag date > Relative Dates
Group Combine dimension members Ctrl+click marks > Group
Set Dynamic in/out binary subset Right-click dimension > Create Set
Bin Discretise continuous measure Right-click measure > Create Bins
TipApplying This in Practice

The most impactful filtering technique for production dashboards is the combination of a context filter (for the main dimension scope) and a Top-N parameter filter (for the detail level). This pattern, “show me the top N products within the selected region”, appears in virtually every professional Tableau dashboard. Master the context + Top-N combination and you will be able to build the filtering logic behind most executive dashboards you encounter.