How to Get AGG in Tableau

Cody Schneider8 min read

If you've spent any time at all building reports in Tableau, you've definitely seen it: the little AGG() wrapper that mysteriously appears on your calculated field pills. For many Tableau learners, this is a source of confusion. What does it mean? Why is it there? And how do you get rid of it? This article will break down exactly what AGG is, why it shows up, and how to work with it effectively to build the reports you need.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

What Exactly is AGG in Tableau?

First, let's clear up a common misconception. AGG() is not a function you can type into a calculated field like SUM() or AVG(). Instead, AGG() is a visual indicator from Tableau that simply tells you the field you’re using is already an aggregate calculation. You can't add another layer of aggregation to it.

To understand this, you need to understand the fundamental difference between measures and dimensions in Tableau:

  • Dimensions are qualitative, categorical data. Think of them as the ways you slice and dice your data. Examples include dates, customer names, product categories, and geographic regions. When you drag a dimension into the view, it creates labels and headers.
  • Measures are quantitative, numerical data. These are the numbers you want to analyze. Examples include sales, profit, quantity, and salary. When you bring a measure into the view, Tableau automatically performs an aggregation on it, most commonly SUM().

For instance, if you drag the [Sales] measure onto your rows, its pill will probably read SUM(Sales). Tableau sums up all the individual sales figures to give you one total number. The AGG() wrapper appears when the field you're using is already a result of one of these aggregations, often from within a calculated field.

In short: If you see AGG(Your Calculation), it means the calculation itself contains an aggregate function like SUM(), MIN(), MAX(), or ATTR(), and Tableau is just letting you know it’s pre-aggregated.

Why Does AGG() Appear on My Pills?

The AGG() indicator typically shows up in a few common scenarios. Understanding them will help you predict its behavior and troubleshoot your calculations.

Scenario 1: Your Calculated Field Contains an Aggregate Function

This is the most frequent reason. If you create a calculated field that uses an aggregate function, the result is an aggregate measure. When you use this new field in your view, Tableau wraps it in AGG().

For example, let's say you want to calculate the profit ratio. The formula would be:

SUM([Profit]) / SUM([Sales])

When you create a new calculated field called "Profit Ratio" with this formula and drag it to the view, the pill won't say SUM(Profit Ratio). It will say AGG(Profit Ratio). Why? Because you can't take the SUM of a calculation that is already based on sums. You've defined its aggregation level within the formula itself.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Scenario 2: You're Using Data Blending

If you're combining data from two different data sources, you'll often see AGG(). When you bring in a field from a secondary data source, Tableau requires it to be aggregated. This is because Tableau must first aggregate the data from the secondary source to the level of detail of the linking fields from the primary source. As a result, measures from the secondary source will always come in as aggregates, often using ATTR() or SUM(), and will be displayed with the AGG() identifier.

Scenario 3: You're Using Table Calculations

Table calculations like RANK(), INDEX(), or WINDOW_SUM() operate on the table of data currently in your visualization. Because these visualizations are almost always built with aggregated measures, the table calculation's result is also considered an aggregate. For example, if you have a bar chart showing SUM(Sales) by Sub-Category and you add a RANK(SUM([Sales])) calculation, that rank pill will show up as AGG(Rank of Sales).

Row-Level vs. Aggregate Calculations: The Core Concept

Understanding the difference between row-level and aggregate calculations is the single most important concept for mastering AGG() and Tableau calculations in general. This distinction determines whether a calculation is performed before or after data is grouped together in your view.

What are Row-Level Calculations?

A row-level calculation is performed for every single row in your underlying data source, before any groupings or aggregations happen in your visualization. The result is a new column in your data source that you can then aggregate later.

Imagine your data looks like this:

A row-level calculation to find the price per item would be:

[Sales] / [Quantity]

Tableau runs this for each row:

When you drag this new "Price Per Item" field into the view, Tableau will ask how you want to aggregate it. You can choose SUM(Price Per Item), AVG(Price Per Item), etc.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

What are Aggregate Calculations?

An aggregate calculation is performed after measures have been aggregated in your view. These calculations rely on aggregate functions like SUM(), AVG(), MIN(), MAX(), COUNT(), COUNTD(), and ATTR().

Using the same data, an aggregate calculation to find the overall average price per item for all orders would be:

SUM([Sales]) / SUM([Quantity])

Tableau would first calculate SUM(Sales) ($300 + $50 + $1000 = $1350) and SUM(Quantity) (3 + 2 + 5 = 10). Then it would perform the division: $1350 / 10 = $135. The result is a single value, and because it was created using aggregated data, Tableau labels it with AGG() in the view.

The distinction is critical: one calculates at the granular row level, the other at a summarized, aggregated level.

Practical Tips for Working with AGG()

Knowing the theory is great, but let's dive into some common problems and how to solve them.

Solving the "Cannot mix aggregate and non-aggregate arguments..." Error

This is arguably the most common error message in Tableau. It occurs when you try to use row-level values and aggregated values in the same calculation.

A classic example is something like this:

IF [Region] = "West" THEN SUM([Sales]) END

Here, [Region] is a non-aggregate (row-level) check, but SUM([Sales]) is an aggregate. Tableau doesn't know how to handle this mix. It needs every part of an IF statement to be at the same level of aggregation.

The Fix: Aggregate the non-aggregate part. You have a few options, but the most common solution is to use the ATTR() function.

IF ATTR([Region]) = "West" THEN SUM([Sales]) END

Understanding the ATTR() Function

So what is ATTR()? ATTR stands for Attribute. It's an aggregation function with a simple rule:

  • If every row in the current group has the same value for the dimension, ATTR([Dimension]) returns that value.
  • If there are multiple different values for the dimension in the current group, ATTR([Dimension]) returns a special asterisk symbol (*).

In our example, if you've broken down your view by Region, then within each partition (e.g., the marks for the "West" region), the value of ATTR([Region]) will be "West." This allows the comparison ATTR([Region]) = "West" to work, resolving the error. It's the perfect tool for when you need to use a dimension inside an aggregate calculation.

How to Disaggregate Measures

Sometimes you don't want Tableau to automatically aggregate measures. For example, in a scatter plot, you might want each mark to represent a single order, not the sum of orders. You can’t drag an AGG() pill to the Dimensions pane, but you can disaggregate the data entirely.

To do this, navigate to the Analysis menu at the top and uncheck Aggregate Measures. This tells Tableau to stop summing everything up and instead show a mark for every single row in your data source. Be careful! If your data source has millions of rows, this can severely impact performance. But for visualizing individual data points, it's the right tool for the job.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Using LOD Expressions as a Workaround

Sometimes you need to perform a calculation at a different grain than what's in your view, which can lead to complex AGG() situations. Level of Detail (LOD) expressions are a powerful way to handle this. Specifically, a FIXED LOD calculation computes an aggregated value but returns it as a row-level result.

For example, say you want to find the average sales per customer, but you only have [Customer Name] and their individual [Sales] transactions. The simple calculation AVG([Sales]) would give you the average transaction size, not the average total sales per customer.

You can solve this with a FIXED LOD:

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

This calculated field, let’s call it "Total Sales per Customer," computes the total sales for each customer and attaches that value to every one of their transaction rows. Because the result is treated as a row-level value, you can drag it into your view and apply a new aggregation, like AVG([Total Sales per Customer]), to get the average of each customer's total.

Final Thoughts

Seeing AGG() in Tableau isn't an error, it's a helpful indicator that tells you a field is already aggregated. The key to mastering Tableau calculations is understanding the crucial difference between row-level work done on every data point and aggregate work done on summarized groups of data. Once that concept clicks, AGG will transform from a source of confusion into a useful guide on your analytics path.

Building reports in tools like Tableau requires learning these specific 'rules' of data - like aggregation levels, LODs, and table calculations. It's a technical skill that takes time to develop. We built Graphed because we wanted to eliminate that friction. Instead of manually configuring pills and debugging calculations, you can just ask in plain English, "show me average sales broken down by region and product category." Graphed instantly handles the connections, aggregations, and visualizations for you, letting you focus on the insights, not the technical setup.

Related Articles