skip to content

In Tableau, why does a Top 10 Customers filter plus a Region filter show fewer than 10 customers?

level: middleimportance: should knowfreq 60%

answer

  1. two filters, same rung of the ladder
  2. neither one sees the other's result
  3. the view shows an intersection
  4. something has to run first
  5. grey pill on the Filters shelf

basics

~20 s

Both are dimension filters, applied at the same stage, so neither sees the other. Tableau picks the top ten across all regions and then intersects that list with the chosen region, leaving only the ones that overlap.

solid answer

~50 s

A Top N filter is a dimension filter, and so is the Region filter — they sit on the same rung of Tableau's order of operations and are evaluated independently, not chained. Tableau computes the top ten customers over the whole (post-context) data set, computes the region restriction separately, and shows the intersection. If only four of the global top ten happen to be in the West, you see four. The fix is to raise Region above the Top N: right-click it on the Filters shelf and choose **Add to Context**. Context filters run before dimension filters, so the top ten is now computed inside the West. The alternative is to rank late instead: a table calculation such as `INDEX() <= 10` used as a filter runs after dimension filters, so it ranks whatever the view already contains.

code

text · 8 lines
text
-- Without context: two peer dimension filters, intersected
Top 10 by SUM(Sales) overall : A B C D E F G H I J
Region = West               : C F J K L M
View shows                  : C F J

-- With Region added to context: Top N computed inside West
Region = West (context)     : C F J K L M ...
Top 10 within West          : C F J K L M N O P Q

go deeper

for a junior

Recognise the symptom and know the name of the fix: a Top N and another dimension filter are peers, and putting the other filter into context makes the top N compute inside it.

for a middle

Explain the intersection precisely — two independent evaluations against the same input, then an AND — and place both filters on the order of operations to justify the fix.

for a senior

Weigh the fix. Know that context materialises a subset that is rebuilt on every value change, and be able to argue for a late table-calculation ranking instead when the filter is interactive.

for a principal

Own the pattern across a team: rankings that quietly disagree with a stakeholder's mental model are a trust problem, so decide a house convention for top-N views and where the narrowing population is declared.

## The symptom You build a bar chart of customers by sales, set the customer filter's *Top* tab to top 10 by `SUM(Sales)`, add a `Region` filter card, and pick West. Nine bars vanish and one stays. Nothing is broken — Tableau did exactly what you asked, and what you asked was not what you meant. ## Why it happens In Tableau's order of operations, a Top N filter *is* a dimension filter. So is a conditional filter, so is a filter card on `Region`, and so is a computed set used as a filter. Everything on that rung is evaluated against the same input — whatever survived the extract, data source and context stages — and the results are intersected. There is no left-to-right chaining and no "the one I dragged first wins". So Tableau answers two independent questions: *which ten customers have the highest total sales overall?* and *which customers are in the West?* The view shows the customers who are in both answers. Company-wide, the top ten might be dominated by East accounts; in West you get whatever few overlap. ```text Top 10 overall: A B C D E F G H I J West members: C F J K L M Intersection: C F J <- 3 bars, not 10 ``` ## The standard fix: context Right-click `Region` on the Filters shelf and choose **Add to Context**. The pill turns grey, and Region moves above the Top N in the order of operations. Tableau now materialises the West subset first and computes the top ten within it, so you get ten West customers ranked by sales — the answer the stakeholder had in mind. The same mechanism explains why a `FIXED` level-of-detail expression "ignores" a filter, and why a computed set based on a condition behaves like Top N: context is the lever for anything that must be evaluated against a narrowed population rather than the whole one. ## The cost of context Context is not a free annotation. Tableau materialises the contexted subset, and every time the context filter's value changes, the subset is rebuilt and everything downstream recomputes. A stable filter — the current fiscal year, an internal-accounts exclusion, a region a viewer sets once — is a good context filter. A date slider someone drags continuously is a bad one, because you pay the rebuild on every drag. ## The other fix: rank late Instead of raising Region, you can lower the ranking. A table calculation runs after all dimension filters, on the result set that came back. Sort the view by `SUM(Sales)` descending and add a filter on `INDEX() <= 10`, or on a `RANK` table calculation, and you are ranking whatever the view already contains. Change the Region filter and the ranking re-derives, no context needed. The trade-off is honest: the late approach asks the database for every customer in the region and trims client-side, so on a wide dimension it moves more data. The context approach trims early but pays for the subset rebuild. On a small dimension the late calculation is usually simpler; on a huge one, context. ## A third option: parameterise N The Top tab accepts a parameter for N, so a viewer can switch between top 5, 10 and 50. That is orthogonal to this bug — it changes how many, not what population they are drawn from — but the two are frequently combined, and it is worth saying so, because a viewer who can change both N and the region will find this bug for you within a minute if you have not fixed it. ## How to talk about it in an interview Do not lead with "add it to context". Lead with *why*: two dimension filters are peers, so the top ten is computed before the region restriction is known, and the view is the intersection. Then give the fix, then give the cost of the fix, then mention the table-calculation alternative. That sequence shows you understand the model rather than having memorised a right-click.

  • What does adding a filter to context actually cost?
    Tableau materialises the contexted subset and rebuilds it whenever that filter's value changes, recomputing everything downstream. Context suits filters that are stable within a session. A control the viewer drags constantly — a date range, a slider — makes every interaction pay for the rebuild, so it is the wrong candidate.
  • How would you get the same result without using context at all?
    Rank late. Table calculations run after every dimension filter, so sorting by SUM(Sales) and filtering on INDEX() <= 10 ranks whatever the view already contains. It costs more data movement, since the source returns every customer in the region and Tableau trims client-side, but it needs no subset rebuild.
  • Does the same explanation cover a computed set that seems to ignore a filter?
    Yes. A computed set's condition or top-N rule is evaluated on the same rung as dimension filters, so it is blind to its peers for exactly the same reason. Adding the other filter to context fixes a set membership problem the same way it fixes a Top N.

saying these in an interview costs you the question

  • Says Tableau applies filters left to right on the shelf
  • Fixes it by raising N until ten bars appear
  • Thinks context filters are purely a performance tweak
  • Believes the Top N filter is a measure filter
  • Adds every filter card to context to be safe

context