Level of detail (LOD) expressions are among the toughest concepts in Tableau to wrap your head around. Whether you're studying for a Tableau certification exam or just starting to build dashboards, it can be hard to know when to use FIXED versus INCLUDE or EXCLUDE, and how LODs fit into the order of operations alongside table calculations. In this post, I'll share my understanding of how LODs work.
Let's start with where LODs are calculated: at the data source. Tableau writes the LOD into the query it sends, and the data source does the aggregating. Table calculations, on the other hand, run afterwards in the data cache Tableau has already retrieved from the data source. This means an LOD calculation has resolved before a table calculation ever sees the data.
This raises a question: how do LODs interact with filters? It depends on whether you're using FIXED or INCLUDE/EXCLUDE. FIXED is computed before dimension filters, so it's independent of them. Say I create the calculated field {FIXED [Category] : SUM([Sales])} and filter the sheet to a single Region. The value won't change, because Tableau calculates it before the filter is applied. To make the filter affect it, I need to convert the filter to a context filter. Context filters (along with data source and extract filters) run before FIXED LODs in Tableau's order of operations.
INCLUDE and EXCLUDE work differently. They are evaluated after dimension filters, so they respond to them like any other calculation in the sheet. INCLUDE adds a dimension, making the calculation more granular. In a sheet with a Region dimension, the calculated field {INCLUDE [Customer Name] : SUM([Sales])} calculates at the level of Region and Customer Name. You'd use INCLUDE when you want to find something like the average sales per customer in each Region, since the sheet doesn't show customers but the calculation needs them. EXCLUDE removes a dimension, making the calculation less granular. In a sheet with Category and Sub-Category dimensions, {EXCLUDE [Sub-Category] : SUM([Sales])} calculates only at the Category level. You'd use EXCLUDE when you want to compare each Sub-Category to its Category, as in a percent of Category total.
In summary: LODs are computed in the data source's query, FIXED runs before dimension filters, and INCLUDE and EXCLUDE run after them. Table calculations come later, on the cached results. And while FIXED ignores the sheet's dimensions and uses only its own, INCLUDE and EXCLUDE start from the sheet's dimensions and then adjust them with their own. I hope this makes your next LOD a little easier to build and understand!
For more reading on Tableau's order of operations, see Joe Macari's post, “How to Talk 'Tablish' - Lesson 3."
