Skip to the page

Excel and BI · senior

Filter context, time intelligence and LOD in Tableau

CALCULATE changes the filters a measure sees. Time intelligence needs a clean Date table. Tableau's FIXED calculations run before dimension filters, so order of operations decides the numbers.

The notes

What you must know

  • CALCULATE evaluates an expression under changed filters (added, replaced or removed). A simple filter such as Store[Region] = "North" replaces any existing filter on that column, so every row and the total show North.
  • KEEPFILTERS keeps the existing filter as well, so the North row shows North and other rows are blank.
  • REMOVEFILTERS(Store) removes all filters on the Store table but keeps other filters such as the Date slicer. ALLSELECTED(Store) keeps the user's selection, so shares add up to 100% of the selection.
  • CALCULATE turns a row context into a filter context (context transition) in calculated columns and iterators.
  • Time intelligence needs a Date table with one row per day, no gaps, whole years, marked as a date table, related on a date column. Blank year-on-year values come from using a fact-table date column, a date-time relationship with times, or a Date table that does not cover last year.
  • YoY: CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date])), then DIVIDE for growth. Indian financial year: TOTALYTD([Total Sales], 'Date'[Date], "03-31").
  • Tableau order of operations: extract and data source filters, context filters, FIXED, dimension filters, INCLUDE and EXCLUDE, measure filters, table calculations.
  • FIXED is computed before dimension filters, so a customer's first purchase date can come from another region even when a Region filter is set. For a per-region cohort add Region to the FIXED list or make Region a context filter.
  • INCLUDE adds a dimension to the level of the view. EXCLUDE removes one. Table calculations run last on the data already in the view.

The red pen

Common traps: mistake → fix

  • Mistake: North Sales shows each row's own region

    Fix: a simple filter in CALCULATE replaces the row's filter.

  • Mistake: REMOVEFILTERS(Store) also removes the year slicer

    Fix: it removes only filters on the Store table.

  • Mistake: A normal filter applies to every Tableau calculation

    Fix: FIXED ignores dimension filters unless they are context filters.

Easy to hard

Questions interviewers ask, easy to hard

  1. What does CALCULATE do to filters?
  2. Your year-on-year measure shows blanks. What do you check?
  3. What is context transition?
  4. In Tableau, what is the order of operations and why does it matter for FIXED?
  5. How do you make a cohort per region in Tableau?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview