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.
{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.
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 to | Use |
|---|---|
| Remove rows from the whole workbook | Data source filter |
| Remove rows from one view | Dimension filter |
| Make a filter apply before an LOD | Context filter |
| Combine members into buckets | Group, or a CASE |
| Flag a subset and reuse it | Set |
| Let the viewer change a number | Parameter |
Try these yourself
- Write a CASE that groups Technology as "Hardware" and everything else as "Other".
- Build a boolean field flagging orders above 50000.
- Total the sales inside and outside that flag, and check they add up.
- Explain why a Region filter does not change {FIXED : SUM([Sales])}.
- Say which filter type you would use to keep only the last two years across the whole workbook.
