# An Introduction to order of operations in Tableau

> This is content from just-tim, the data-and-analytics channel by Tim Ngwena (formerly 'Tableau Tim'). Tim has 12+ years of hands-on BI experience and covers Tableau most of all, plus Power BI, Looker, Hex, SQL and data modelling, the analytics industry, and the craft of doing the job — always tool-agnostic and honest about the trade-offs.

- **Author:** Tim Ngwena (just-tim, https://just-tim.com/about)
- **Published:** 2021-03-18
- **Format:** Video · 14 min watch · transcript available
- **Topics:** Data visualisation, Analytics
- **Tools:** Tableau (calculated fields, filters, lod expressions)
- **Canonical:** https://just-tim.com/posts/an-introduction-to-order-of-operations-in-tableau
- **Watch:** https://youtu.be/KbKSzD3okrQ

I introduce Tableau's order of operations, the sequence in which Tableau processes filters and calculations. Using the documentation diagram and a Superstore example, I show how a top N filter clashes with a dimensional filter, and how data source and context filters fix the wrong result.

## Key takeaways

- Tableau processes filters and calculations in a fixed sequence: extract filters first, then data source, context, sets, conditional and top N filters, then dimensional filters, LODs and finally trend and reference lines
- A top N filter sits above dimensional filters in the order, so a state filter applied alongside it won't be respected before the top N is calculated
- Moving a dimensional filter into a data source filter forces it to apply before the top N, but it removes those values from the entire data source
- A context filter (shown greyed out) is the more flexible fix, applying before top N but only within the current sheet so other states remain available
- Understanding the order of operations explains both wrong results and slow performance, since filters higher up the chain are computed earlier

## Chapters

- 0:41 What order of operations means
- 1:53 Walking through the operations diagram
- 3:56 Top N filter example in Superstore
- 6:42 Diagnosing the wrong result
- 7:58 Fixing it with a data source filter
- 9:12 Using a context filter instead
- 11:20 Why it matters and further resources

Watch the full video, read the transcript and use chapter deep-links on the page: https://just-tim.com/posts/an-introduction-to-order-of-operations-in-tableau

---
just-tim — Data and analytics, with a point of view. · https://www.youtube.com/channel/UC7HYxRWmaNlJux-X7rNLZyw · https://twitter.com/TableauTim · https://www.linkedin.com/in/timngwena
