# Include Level of Detail Calculation: Tableau Functions

> 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-23
- **Format:** Video · 1530 min watch · transcript available
- **Topics:** Data visualisation, Analytics
- **Tools:** Tableau (calculated fields, lod expressions)
- **Canonical:** https://just-tim.com/posts/include-level-of-detail-calculation-tableau-functions
- **Watch:** https://youtu.be/0tutQ9c3lw4

I walk through the INCLUDE level of detail calculation in Tableau, building from a simple average sales example to show how INCLUDE adds a dimension to the viz level of detail. I contrast it with FIXED to demonstrate why they can give the same answer in one context but differ entirely when the question changes, then tackle a more complex nested aggregation example.

## Key takeaways

- The Superstore data set's grain is at the product level, not the order level, so any aggregation is really averaging individual product rows unless you change the level of detail
- INCLUDE works in conjunction with the viz level of detail, adding a dimension to whatever is already on rows, columns and most marks (the tooltip being the exception, which uses ATTR)
- FIXED and INCLUDE can return identical results in one context but diverge the moment you change the dimensions in the view, so you must keep asking whether the calculation still answers your question
- FIXED can double count when its dimension doesn't align with the viz, whereas INCLUDE effectively creates a combined dimension (e.g. order ID plus subcategory) for the correct grain
- You can nest aggregations inside INCLUDE, such as MAX(sales) per manufacturer, then take an AVG across cities, and use the summary and tabular detail views to validate what's being computed

## Chapters

- 0:00 Introduction and prerequisites
- 0:53 Understanding the data grain
- 3:33 Validating the average in the summary
- 4:19 Writing the INCLUDE calculation
- 8:30 INCLUDE versus FIXED
- 9:56 Why FIXED double counts on subcategory
- 14:10 Summarising how INCLUDE works
- 15:20 A more complex nested example
- 23:43 Resources and order of operations

Watch the full video, read the transcript and use chapter deep-links on the page: https://just-tim.com/posts/include-level-of-detail-calculation-tableau-functions

---
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
