How Does Tableau Know at Which Level to Aggregate Values?

Cody Schneider

One of the most foundational concepts in Tableau can also be one of the most confusing: how, exactly, does it know how to calculate your numbers? You drag "Sales" into the view, and you get a single big number. Then, you drag "Region" into the view. Suddenly, that number splits into four different values. How did it know to do that? This article will explain exactly how Tableau determines the level at which it aggregates your data.

Understanding this concept, often called the “Level of Detail” (or LOD), is the difference between fighting with Tableau and making it work for you. We’ll cover what dimensions and measures are, how they control aggregation, and how you can override the default behavior for more complex calculations.

Diving into Dimensions vs. Measures

Tableau’s ability to aggregate hinges on its classification of your data fields into two simple categories: Dimensions and Measures. When you connect a data source, Tableau scans the columns and tries to make an educated guess, though you can always reclassify them yourself.

  • Dimensions: These are qualitative, categorical fields that you use to slice and dice your data. Think of them as the "by" in your analysis questions: "Sales by Region" or "Profit by Product Category." In the Tableau interface, dimensions are typically blue pills. Common examples include names, dates, and geographical locations like Customer Name, Order Date, or State. They set the context and define the level of granularity for your view.

  • Measures: These are quantitative, numerical fields that can be aggregated. They are the actual numbers you're analyzing - things you can count, sum up, or average. In Tableau, measures are usually green pills. Examples include fields like Sales, Profit, Quantity, or Clicks.

Here’s the golden rule that answers our main question: Tableau aggregates measures up to the level of detail set by a worksheet's dimensions. Let's break that down with a practical example.

Building a View: How Aggregation Works in Practice

The best way to see how this works is to build a simple visualization and observe how Tableau behaves with each step. We’ll use the standard "Sample - Superstore" dataset that comes with Tableau.

Step 1: Just a Measure (The "Highest" Level)

Imagine you have a new, empty worksheet. You find the Sales measure in your data pane and drag it onto the Text card on the Marks shelf. What happens?

Tableau displays a single number: $2,297,201. This is the sum of every single sale in the entire dataset. Without any dimensions to slice the data, the level of detail is the entire data source. Tableau defaults to SUM() aggregation and applies it to the Sales measure across every row.

Step 2: Adding a Single Dimension

Now, let’s see what happens when we introduce a way to group the data. Drag the Region dimension onto the Rows shelf.

Instantly, the view changes. Instead of one large number, you now have four rows, one for each region (Central, East, South, West), each with its own sales value.

What happened here? By adding the Region dimension, you changed the level of detail. You effectively told Tableau, "Don't just give me the total sales, give me the sum of sales for each region." The SUM(Sales) calculation is now executed independently for each of the four regions. The granularity of the view is now at the Region level.

Step 3: Adding Another Dimension

Let's make it even more detailed. Find the Category dimension and drag it to the right of the Region pill on the Rows shelf.

The view changes again. Each region is now broken down further into three sub-rows: Furniture, Office Supplies, and Technology. You now have twelve marks (4 regions x 3 categories), each showing the sum of sales for that specific combination. For example, you can see sales for Furniture within the Central region, Office Supplies within the Central region, and so on.

The level of detail is a combination of all dimensions present: the Region AND Category level. Every time you add a dimension, you increase the number of "headers" or "labels" in your view, making the display more granular and causing measures to be recalculated for each unique intersection of those dimension members.

Controlling the Granularity

"Granularity" is just a fancy word for how detailed your view is. A highly granular view has data broken down into very small pieces (e.g., sales per day per customer), while a low-granularity view is highly summarized (e.g., total annual sales).

  • Increasing Granularity: Adding dimensions to your Rows, Columns, Color, or Detail shelves makes your view more granular.

  • Decreasing Granularity: Removing dimensions from your view makes it less granular and more aggregated.

Think of it like nested folders on your computer. Starting with a single drive (total sales), then opening a folder for each region, and inside those, a folder for each category. Dimensions create this structure on the fly.

Changing the Aggregation Type

So far, we've only been using SUM(). This is Tableau's default for most numerical data types, but you're not locked into it. The level of detail (Region and Category) stays the same, but the calculation you perform changes.

To change it, simply right-click the SUM(Sales) pill in your view, go to "Measure (Sum)," and select a different aggregation. For example, if you select "Average," the viz instantly updates to show the average sale amount for each Region/Category combination, not the total.

This is an important distinction. The dimensions in the view define the "buckets" that your data gets sorted into. The aggregation type (SUM, AVG, MIN, MAX, ATTR, COUNT) defines what mathematical operation you perform on all the numbers that fall into each bucket.

Need More Control? Introducing Level of Detail (LOD) Expressions

Sometimes, the default behavior isn't enough. You might need to compute an aggregation at a level of detail that is different from the level of detail in your current view. For example, you may want to compare a region's sales to the overall average across all regions or see what percentage of a customer's total purchases occurred in a specific category.

This is where Level of Detail (LOD) Expressions come in. They let you explicitly declare the level at which a measure should be aggregated, irrespective of the dimensions in your view. There are three types:

1. FIXED LOD

FIXED calculates an aggregate at the exact level you specify, no matter what. It "fixes" the context to a certain set of dimensions.

  • Example: Calculating each customer's lifetime value.

  • Formula: { FIXED [Customer Name] : SUM([Sales]) }

  • This expression creates a new field. For every row in your data, this field will hold the total sales for that customer across their entire history. You can then drag this new calculated field into a view showing regions to find the average lifetime value of customers in each region.

2. INCLUDE LOD

INCLUDE calculates an aggregate at a finer level of detail (a lower level) than what's currently in the view. It adds a specified dimension to the view context for that particular calculation.

  • Example: Your view shows total sales by State, but you want to calculate the average sales per City and then show the sum of those averages for each state.

  • Formula: { INCLUDE [City] : AVG([Sales]) }

  • This forces the AVG(Sales) calculation to happen at the city level, even if City isn't in your main view, before it gets aggregated up to the state level.

3. EXCLUDE LOD

EXCLUDE is the opposite of INCLUDE. It subtracts a dimension from the view's level of detail, performing a calculation at a higher, less granular level.

  • Example: Your view shows sales by Region and Category. You want to calculate the percentage of total regional sales that each category contributes.

  • Formula: SUM([Sales]) / SUM({ EXCLUDE [Category] : SUM([Sales]) })

  • The EXCLUDE [Category] part calculates the total sales for the region (without slicing it by category) so you can use it as the denominator in your percentage of total calculation.

LOD expressions are an advanced topic, but they powerfully demonstrate how you can override Tableau's default aggregation behavior to answer more sophisticated business questions.

Final Thoughts

In short, Tableau's aggregation logic is determined by the "level of detail" in your worksheet. This level is defined by the dimensions you drag into your view. More dimensions mean more granularity and more specific aggregations. Fewer dimensions result in a more summarized, higher-level view. You can then take manual control of this process when needed by leveraging powerful LOD expressions.

While mastering these concepts is rewarding, we know the learning curve for business intelligence tools can be time-consuming. It often feels like you have to become a data technician just to ask a straightforward question. We built Graphed to remove this friction entirely. Instead of dragging pills, structuring calculations, and writing complex expressions, you can just ask a question in plain English, like "what were our total sales by region and category last quarter?" and get a live, interactive visualization instantly. Graphed automates the work of building dashboards so you can spend your time on insights, not setup.