🚀 New batches open: Advanced Excel • Power BI • SQL • AI for Analytics — Book a free demo

Day 9 — Filters, groups, sets and parameters

Four ways to narrow down data, and the order Tableau applies them in.

The order of operations

This diagram explains more confusing Tableau behaviour than anything else. Filters do not all run at the same time.

1. Extract filters 2. Data source filters 3. Context filters 4. FIXED level of detail expressions 5. Dimension filters 6. Measure filters 7. Table calculations
FIXED runs before dimension filters That is why a normal filter on Region does not change a {FIXED : SUM([Sales])} total. It is not a bug - the LOD was computed before the filter ran. If you need the filter to apply first, promote it to a context filter, which moves it above the LOD in that list.

Seeing it

Every calculation on this page runs against the Orders data source below - 48 rows, dimensions in blue, measures in green, exactly as Tableau colours them.

The second column stays at the full 30,37,800 for every region. Imagine a Region filter on this view: the first column would change, the second would not.

Groups - combining values by hand

A group merges dimension members into a bigger bucket. In the interface you select members and click the paperclip; in a calculation it is a CASE.

Group or calculated field? A group is faster to make and easy for a colleague to edit. A calculated field is reproducible, documented and survives a data refresh that introduces new members. For anything that has to run every month, write the calculation.

Sets - a membership test

A set answers a yes/no question about every dimension member. The calculation equivalent is a boolean field.

Sets become powerful when combined - "customers who bought last year AND this year" is a set intersection, and that is a question a filter alone cannot answer.

Parameters - letting the user choose

A parameter is a single value the viewer controls, which calculations can then read. There is no interface here, so the closest equivalent is changing a number in the calculation and re-running it.

In a real workbook those two would be one calculation reading [Threshold], and the viewer would drag a slider. Edit the numbers above and re-run to feel what the viewer would experience.

Choosing between them

You want toUse
Remove rows from the whole workbookData source filter
Remove rows from one viewDimension filter
Make a filter apply before an LODContext filter
Combine members into bucketsGroup, or a CASE
Flag a subset and reuse itSet
Let the viewer change a numberParameter

Try these yourself

  1. Write a CASE that groups Technology as "Hardware" and everything else as "Other".
  2. Build a boolean field flagging orders above 50000.
  3. Total the sales inside and outside that flag, and check they add up.
  4. Explain why a Region filter does not change {FIXED : SUM([Sales])}.
  5. Say which filter type you would use to keep only the last two years across the whole workbook.