The three Level OF Detail (LOD) expressions in Tableau are fairly intuitive names for what they actually do. They fix the measure at a certain level of detail, include dimensions that are not in the view, and exclude dimensions that are not in the view.


In the chart below the granularity is set at the region as we are slicing and dicing by GDP. We could increase the grain by adding the country to the rows shelf. This would make our analysis by both region and country. This has changed the level of detail and made our chart more granular. What if we wanted it both ways though? I want to see GDP by Region and GDP by Country! Enter the LOD expression.

The LOD expressions are easy to syntax in Tableau and are all the same structure.

  1. Open mustachioed bracket {
  2. Your LOD of choice FIXED, INCLUDE or EXCLUDE
  3. zero or more dimensions you want to be fixed, included or excluded
  4. Colon :
  5. aggregated measure
  6. Closing mustachioed bracket }

So back to the chart. I have GDP sliced by region and country but I want to compare each row by region only so I want to exclude country.

{EXCLUDE [country] : SUM([GDP})}

Now when we add the new calc to the shelf we see that one side has country gdp and the other has region gdp (without the countries). This is useful as well if we want to add more analysis, such as, contribution to the regions GDP by a country.

Create a new calculated field that divides SUM(GDP)/SUM(exclude country GDP). Then a quick table calc of percent of total by pane (down) and we have each countries contribution to GDP in the region.

The beauty of LOD expressions is they allow for multiple levels of detail on the same worksheet. Great for comparisons like the above where we can see the UK contributes 13% towards the European region GDP.



The Data School
Author: The Data School