Level of Detail Part 2: Syntax & Order of Operations

by Peter Silvester

In the part one of this series we looked at what Level of Detail is in Tableau and mentioned how LoD calculations enable us to aggregate values on our own terms regardless of what is in the view. In this blog we will explore in more detail the different types of LoD calculation and how to create them in Tableau.

 

syntax

 

Level of Detail Syntax

  • The first point to make about the syntax of LoD calculations is that they must always be surrounded by curly braces which will turn blue to indicate you are on the right track.
  • LoD expressions must also always start with one of the 3 scoping keywords – Fixed, Include and Exclude – which determine how the aggregation will be performed (full explanation of each in pt. 3).
  • Enter the dimension(s) that you want the expression to affect before a separating colon.
  • Finish off the calculation with the measure that you want to aggregated (you must specify the aggregation in the expression

 

Order of Operations

I personally think Fixed is the easiest of the scoping keywords to use and a lot of the time it can be used in the place of either of the other two. However the scoping keywords are affected differently by filters due to the order of operations in which calculations are performed so a Fixed expression will not always be right for the situation.

As the following diagram shows Fixed expressions come before dimension filters so will ignore any filter in the shelf unless it is put in context.  If you want your calculation to be affected by what you’ve dropped in as a filter then you will have to use Include or Exclude.

 

order-of-ops

 

 

 

 

 

 

Avatar

Peter Silvester

Thu 01 Dec 2016

Wed 23 Nov 2016

Tue 22 Nov 2016