Skip to content

A Quick Guide to Tableau Level of Detail Expressions

Published by Concentra

Discover analytics solutions from Concentra


Concentra’s analytics and business intelligence teams turn information into insight to give you the edge from your data. Learn more.

Have you ever received the following error message when creating a calculated field in Tableau: “Cannot mix aggregate and non-aggregate arguments with this function”?

Don’t be frustrated. From version 9.0 onwards, users can leverage Level of Detail (LOD) Expressions to avoid this error.

Before these expressions were supported in Tableau, it was not possible to create calculations at a level of detail other than the view level. Let’s look at a business example. You want to compare the quantity of product sold per customer to the average quantity sold per customer in a country. Before LODs were available, you might attempt it with an expression similar to Figure 1 below and receive an error message. Thanks to LODs, you can now use the syntax shown in Figure 2 and get your answers exactly.

Figure 1

Figure 2

LOD Types

There are three types of LODs: Fixed, Include and Exclude. It is useful to be aware of what each can do:

{FIXED [ Region ]: Avg ( [Sales] )}

This expression calculates the average sales per Region, regardless what other dimensions are in the view.

{INCLUDE [ Product Name ]: Avg ( [Sales] )}

This expression calculates the average sales at the level of detail defined in the view, but includes the dimension Product Name, even if Product Name is not in the view.

This expression calculates the average sales at the level of detail defined in the view but does not include Category (the dimension) as part of the level of detail, even if Category is in the view.

Use Cases

So now we know the different types of LODs and how to write them, we can ask ourselves: what are LODs used for? LODs have many useful applications, these include the following: