Level of Detail(LOD) Expression in Tableau

Level of Detail(LOD) Expression in Tableau

4 mins read714 Views Comment
Vikram
Vikram Singh
Assistant Manager - Content
Updated on Jun 10, 2022 06:47 IST

In this article, we will discuss about the Levels of Detail (LOD) expression in tableau, types of LOD expressions and how to create LOD expression in tableau.

2022_06_feature-images_lod.jpg

Table of Content

Firstly we will discuss why we need LOD expressions in the tableau or what problem we are trying to solve through LOD expressions then we will move to what are LOD expressions in the tableau.

Recommended online courses

Best-suited Tableau courses for you

Learn Tableau with these high-rated online courses

39.54 K
2 hours
– / –
45 hours
– / –
4 weeks
– / –
4 weeks
2.25 K
4 weeks
Free
12 hours
– / –
1 hours
19.89 K
16 hours
– / –
3 hours
19.7 K
6 months

Why do we need LOD expression in Tableau?

Let’s understand the problem with the help of an example

In Sample Superstore data, using tableau we can easily find the details like:

  • Maximum Sale/Profit/Discount of product
  • Minimum Sale/Profit/Discount of product
  • Highest selling product
  • Least selling product
  • State producing maximum profit
  • Category of products
  • Sub-category of products

But, what if we have to find:

  • In which week of Q3 2018, did the company get the maximum/minimum order?
  • In which quarter company makes the maximum profit?
  • A number of days per quarter in which the company sells more than 50 products of each category?

To solve problems like this, LOD comes into action. In Tableau 9.0 LOD comes into action. It allows users to express powerful concepts using simple concepts.

Must Check: What is Tableau?

Must Check: Tableau Online Courses & Certifications

Now, let’s move on to know what LOD expressions are.

What are LOD expressions in Tableau?

The Level of Detail (LOD) expressions allow computing the value at the data source and the visualization level. It is a powerful technique to solve the problem that includes multiple levels of granularity in a single visualization.

They can be performed at:

  • a more granular level (INCLUDE)
  • a less granular level or (EXCLUDE)
  • an entirely independent level (FIXED)
How to Create a Word Cloud in Tableau
How to Create a Forecast in Tableau
How to Create Hierarchies in Tableau

How to create LOD expression in Tableau?

There are three types of LOD expressions:

  • FIXED
  • INCLUDE
  • EXCLUDE

Now, we will see how to create each LOD expressions

FIXED

  • Compute value using the specified dimension, without reference to the dimension in the view
  • Syntax: {[FIXED] <declaration of dimension> : <expression to aggregate>}

Example:

Problem Statement: Calculate the total Profit by Category without calculating for each sub-category present in the category.

Steps to Create:

  • Connect the Sample Superstore Data
  • Drag and Drop Category and Sub-category into the row shelf
  • Drag and Drop Category into Color in the Marks Pane
  • Analysis -> Create Calculated Fields
    • Change the name Profit by Category
    • Write the formula
2022_06_LOD_FIXED.jpg
  • Drag and Drop Profit by Category to Text in Marks Pane
2022_06_LODEXPRESSION_FIXED.jpg
Highlight Actions in Tableau
Dimension and Measure in Tableau
How to Create Group in Tableau

INCLUDE

  • INCLUDE works just opposite FIXED
  • It includes view dimensions in calculation i.e. it will include an additional dimension along with the one specified
  • Fields based on INCLUDE LOD will change as you add or remove dimensions from the view.
  • Syntax: {[INCLUDE] <declaration of dimension> : <expression to aggregate>}

Example: 

Problem Statement: Calculate the average regional profit for each category.

 Steps to Create

  • Connect to Sample SuperStore data
  • Drag and Drop Category into the row shelf
  • Analysis -> Create Calculated Fields
    • Change the name Average Regional Profit
    • Write the formula
2022_06_LOD_INCLUDE.jpg

Note: It is not mandatory to use the aggregation function in the formula, you can change it in Marks Pane -> Right-Click on selected Field -> Select Measure -> Select AVG

  • Double Click on Average Regional Profit
2022_06_LOD_INCLUDE_average-regional-profit.jpg

EXCLUDE

  • It is used to eliminate the dimension from lower granularity levels
  • It calculates the dimension from the higher level of granularity
  • Useful for ‘percentage of total’ or ‘difference from overall average’ scenario
  • Syntax: {[EXCLUDE] <declaration of dimension> : <expression to aggregate>}

Example:

Problem Statement: Sales of the product are given on the basis of City, State and Region, now eliminate the City dimension when computing the sales.

Steps to Create

  • Connect to Sample SuperStore data
  • Drag and drop Region, State, and City into row shelf
  • Drag and drop Sales into Text in Marks Pane
2022_06_LOD_EXCLUDE.jpg
  • Analysis -> Create Calculated Fields
    • Change the name Exclude City Sales
    • Write the formula
2022_06_LOD_EXCLUDE_FORMULA.jpg
  • Double click on Exclude City Sales
2022_06_LOD_EXCLUDE_result.jpg

Now, the sales in computed only at State and Region levels.

Table-Scoped

LOD expressions can be defined at the table level without using any scoping keywords.

Example:

  • {MAX([Profit])}
    • returns maximum profit from the entire table
  • {FIXED : MAX([Profit])}
    • It is equivalent to FIXED LOD with no dimension declaration

Limitation of LOD expression

  • Expressions are not shown on Data Source Page
  • Table calculation can’t be used within a LOD
  • It gives an unreliable view when floating values are used
Sort Data in Tableau
Data Aggregation in Tableau
About the Author
author-image
Vikram Singh
Assistant Manager - Content

Vikram has a Postgraduate degree in Applied Mathematics, with a keen interest in Data Science and Machine Learning. He has experience of 2+ years in content creation in Mathematics, Statistics, Data Science, and Mac... Read Full Bio