Level of Detail expressions

Level of Detail expressions (also known as LOD expressions) allow you to compute values at the data source level and the visualization level. However, LOD expressions give you even more control on the level of granularity you want to compute. They can be performed at a more granular level (INCLUDE), a less granular level (EXCLUDE), or an entirely independent level (FIXED).

For example, let's create a new calculated field called Cases per County:

In fact this newly calculated field represent the averaged number of COVID-19 cases per counties of South Carolina in a time frame of a month. Furthermore, you can control the time frame by using the defined parameter of Month Parameter to choose your time frame. The thing that we expect is that the rate of increase at the beginning of the pandemic should be high but it reaches a plateau while the number of daily cases remains high:

Types of LOD expressions

There are three types of LOD expressions you can create in Tableau:

  • FIXED

  • INCLUDE

  • EXCLUDE

You can also scope an LOD expression to the table. This is called a Table-Scoped LOD expression.

FIXED LOD

FIXED level of detail expressions compute a value using the specified dimensions, without reference to the dimensions in the view. Let's change INCLUDE keyword in the Cases per County to FIXED and see its effect on final visualization:

The results of the averaged cases per counties are changed when the LOD changed from an INLCUDE one to FIXED because Tableau tries to fix the variable county and then calculate the averages which is obviously wrong in this case, where we want to visualize the average of cases per county in comparison to INCLUDE LOD.

INCLUDE LOD

INCLUDE level of detail expressions compute values using the specified dimensions in addition to whatever dimensions are in the view.

INCLUDE level of detail expressions can be useful when you want to calculate at a fine level of detail in the database and then re-aggregate and show at a coarser level of detail in your view. Fields based on INCLUDE level of detail expressions will change as you add or remove dimensions from the view. The visualization in this mode is shown in the first section.

EXCLUDE LOD

EXCLUDE level of detail expressions declare dimensions to omit from the view level of detail.

EXCLUDE level of detail expressions are useful for ‘percent of total’ or ‘difference from overall average’ scenarios. They are comparable to such features as Totals and Reference Lines.

EXCLUDE level of detail expression cannot be used in row-level expressions (where there are no dimensions to omit), but can be used to modify either a view level calculation or anything in between (that is, you can use an EXCLUDE calculation to remove dimension from some other level of detail expression).

For example, let's define a new calculated field and exclude county and fix the date:

The final visualization looks like this.

Table-Scoped

It is possible to define a level of detail expression at the table level without using any of the scoping keywords. For example, the following expression returns the minimum (earliest) date for the entire table:

{MIN([Date])}

This is equivalent to a FIXED level of detail expression with no dimension declaration:

{FIXED : MIN([Date])}

The workbook to reproduce the visualizations in this section is shared here: https://bit.ly/2Iqed9m