How to Use INCLUDE in Tableau

Cody Schneider9 min read

The real power of Tableau comes from going beyond simple drag-and-drop charts to create more nuanced calculations. One of the most useful tools for this is the INCLUDE level of detail (LOD) expression, which lets you perform calculations at a different granularity than what’s shown in your visualization. This article unpacks exactly what INCLUDE does, when to use it, and provides step-by-step examples you can follow.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

First, What Are Level of Detail (LOD) Expressions?

Before jumping into INCLUDE specifically, it helps to quickly recap what Level of Detail expressions are for. In a nutshell, LOD expressions allow you to compute values at a specific level of data granularity, which can be independent of the dimensions you have in your chart or table (what Tableau calls the "viz level of detail" or viz LOD).

Think about this common scenario: your chart shows total sales by marketing region. The level of detail is "Region." But what if you wanted to also show the average sales per customer within each region? Calculating an average per customer requires a finer level of detail (the "Customer" level) than your chart currently displays.

This is where LOD expressions come in. They give you control over the granularity of your calculations. There are three types:

  • FIXED: Calculates a value at a level of detail defined only by the dimensions you specify in the formula. It ignores dimensions and most filters in your current view.
  • INCLUDE: Calculates a value using the dimensions in your current view plus any additional dimensions you specify in the formula. It computes a more granular value.
  • EXCLUDE: Calculates a value using the dimensions in your current view but subtracting any dimensions you specify in the formula. It computes a less granular value.

This article focuses entirely on INCLUDE, which is perfect for when you need to "look down" at a finer detail for a calculation while keeping your overall visualization simple.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

When to Use the INCLUDE LOD Expression

The primary reason to use an INCLUDE LOD expression is when you need an aggregation that’s more granular than your main chart. It allows the calculation to temporarily "include" another dimension, perform an aggregation, and then bring that result back up to the level of your visualization.

Here are some classic situations where INCLUDE is your answer:

  • Average Customer Sales by Region: Your view is aggregated at the Region level, but to get a meaningful "average customer value," you first need to calculate the total sales for each customer. INCLUDE [Customer Name] lets you do that.
  • Average Order Value by Product Category: Your view shows Product Category, but you want to find the average value of each order that contained a product from that category. You need to sum the sales at the Order ID level first. INCLUDE [Order ID] is perfect for this.
  • Maximum Daily Sales per Month: You want a bar chart showing the single best day of sales for each month. Your view is at the Month level, but the calculation must first find the total sales for each Day. INCLUDE DAY([Order Date]) gets the job done.

In all these cases, the logic is the same: the analysis requires an intermediary calculation at a more detailed level than what's being displayed.

Breaking Down the INCLUDE Syntax

The syntax for an INCLUDE LOD expression is straightforward. Once you understand the components, writing your own becomes much easier.

Here's the basic structure:

{ INCLUDE [Dimension 1], [Dimension 2] : AGG([Measure]) }

Let’s dissect this:

  • { } (Curly Braces): These brackets signal to Tableau that you're creating a Level of Detail expression. You must have an opening and a closing brace.
  • INCLUDE: This is the keyword that specifies the type of LOD.
  • [Dimension 1], [Dimension 2]: This is a comma-separated list of the dimension(s) you want to add to the viz LOD for this specific calculation.
  • : (Colon): The colon acts as a separator, dividing the dimensional context from the aggregation you want to perform.
  • AGG([Measure]): This is the aggregate calculation (e.g., SUM(), AVG(), MAX(), MIN()) that Tableau will run at the new, more granular level of detail.

So, the formula { INCLUDE [Customer ID] : SUM([Sales]) } reads like plain English: "For each row, include the customer ID, and then for that fine-grained level, calculate the sum of sales."

Step-by-Step Example: Calculating Average Sales Per Customer by Region

This is arguably the most common use case for an INCLUDE LOD and a perfect way to see it in action. Let’s say we’re using Tableau’s sample "Superstore" dataset.

The Goal: To build a bar chart showing the average of total customer sales for each sales Region. We want to understand, on average, how much a customer in the 'West' region spends in total compared to a customer in the 'East' region.

Without an LOD, if you put Region on the Rows shelf and AVG([Sales]) on the Columns shelf, you’d get the average sales per transaction line - a very different and less useful number. We need to sum sales per customer first, then average those sums.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 1: Create the Calculated Field with 'INCLUDE'

First, we need to create a calculated field that computes the total sales for each customer.

  1. Right-click anywhere in the Data pane on the left and select "Create Calculated Field..."
  2. Name your new calculated field something descriptive, like "Sales per Customer".
  3. In the formula box, type the following expression:
{ INCLUDE [Customer Name] : SUM([Sales]) }

Let's unpack this formula. It tells Tableau: "For the calculation, in addition to any dimensions in my view (like Region), I also want you to INCLUDE the [Customer Name] dimension. At that combined level of detail (Region + Customer Name), calculate the SUM of [Sales]."

Essentially, this creates a temporary result table where you have the total sales for every single customer.

Step 2: Build the Visualization

Now that we have our powerful new calculated field, we can use it to build the chart.

  1. Drag the "Region" dimension from the Data pane onto the Rows shelf. You'll see the four regions listed.
  2. Drag your newly created measure, "Sales per Customer," from the Data pane onto the Columns shelf. A bar chart will automatically appear.

But wait — the numbers might look higher than expected. This is because Tableau, by default, aggregates a new measure using SUM(). Our chart currently shows the sum of all the customer sale totals. We need the average.

Step 3: Adjust the Aggregation

This is the final, and most important, step. We need to tell Tableau how to aggregate our LOD expression in the final view.

  1. In the Columns shelf, right-click the green "SUM(Sales per Customer)" pill.
  2. In the context menu that appears, go down to "Measure" and select "Average".

Instantly, the bar chart updates. You have now correctly calculated the average total spending per customer, broken down by region. The bar for the 'West' region now shows the true average value of a customer's total purchases in that area.

Another Example: Identifying Maximum Daily Sales by Month

Let's try another scenario. You want to see the performance of your best sales day within each month to spot seasonality or the impact of monthly promotions.

The Goal: Create a bar chart showing the single best sales day for each month.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 1: Create the 'INCLUDE' Calculation

First, we'll create the calculation to find the total sum of sales for each unique day.

  1. Create a new calculated field and name it "Daily Sales Total".
  2. Enter the following formula:
{ INCLUDE DATETRUNC('day', [Order Date]) : SUM([Sales]) }

This formula uses DATETRUNC('day', ...) to ensure we're looking at the exact calendar day. It instructs Tableau: "For each row, include the specific day of the transaction. Then, for each day, calculate the total sum of sales."

Step 2: Put it into a View

  1. Drag "Order Date" onto the Columns shelf. By default, it will probably show YEAR(Order Date). Right-click the blue pill and change it to show the discrete MONTH(Order Date).
  2. Drag your new "Daily Sales Total" measure onto the Rows shelf.
  3. Once again, Tableau defaults to SUM(). Right-click the green "SUM(Daily Sales Total)" pill, navigate to "Measure", and this time select "Maximum".

And there you have it. The chart now clearly displays the value from the top-performing sales day for January, February, March, and so on. You're comparing the peaks of each month, not their total volumes.

Key Tips and Final Considerations

  • Don't Forget the Final Aggregation: Remember that an LOD expression is just a calculation. How you aggregate it in your visual (SUM, AVG, MIN, MAX) is a separate step that defines your final insight. It's the most common mistake beginners make.
  • INCLUDE Respects Regular Filters: Unlike FIXED, INCLUDE LOD expressions are affected by most standard dimension filters on your worksheet. If you filter out a product category, the INCLUDE calc will re-run without that data.
  • Test Your Work In a Table: When you're first getting started with LODs, it's incredibly helpful to build a simple crosstab to validate your numbers. For the customer example, you could create a table with Region, Customer Name, and SUM(Sales) alongside the result of your INCLUDE calculation to see exactly how it works.

Final Thoughts

Tableau's INCLUDE LOD expressions open up a whole new level of analytical power, letting you craft calculations that answer deeper, more complex business questions. They give you the flexibility to compute values at a finer detail than your chart shows, all without complicated table joins or data prep.

We know that getting comfortable with data analytics tools and syntax takes time. That’s why we built Graphed - to remove the learning curve entirely. With our tool, you connect your data sources, then skip the calculated fields and LODs. You can simply ask in natural language, "Show me a chart of the average sales per customer by region." We turn your questions into charts and dashboards instantly, ready to share with your team. To get insights without the tutorials, check out what you can do with Graphed.

Related Articles