Meritshot Tutorials

  1. Home
  2. »
  3. Different Types of LOD Expressions (Fixed, Include, Exclude)

Tableau Tutorial

Different Types of LOD Expressions (Fixed, Include, Exclude)

Different Types of LOD Expressions (Fixed, Include, Exclude)

Definition:
FIXED LOD expressions are used to aggregate data at a specific level of detail that remains constant regardless of the view’s dimensions or filters. This means the calculation is based on a predefined level of granularity, and any filters or dimensions in the current view do not affect the result of this calculation.

Syntax:

FIXED [Dimension1], [Dimension2]: Aggregation([Measure])

Use Case:
FIXED LOD expressions are ideal when you need to perform calculations based on a static level of detail that does not change with the dimensions or filters in the view. They are useful for calculating metrics like overall totals or averages that need to remain consistent regardless of the view’s state.

Example:

  • Total Sales per Product:
    To compute the total sales per product across all regions, you use:

FIXED [Product]: SUM([Sales])

This calculates the total sales for each product, ignoring any regional filters or dimensions.

  • Average Profit per Product Category:
    To find the average profit for each product category irrespective of the view’s dimensions, you use:

FIXED [Product Category]: AVG([Profit])

This calculates the average profit for each category, even if you have different dimensions or filters applied to your view.

2. INCLUDE LOD Expression

Definition:
INCLUDE LOD expressions aggregate data by incorporating additional dimensions from the view into the calculation. The aggregation is performed at the granularity of the view plus any extra dimensions specified in the INCLUDE expression.

Syntax:

INCLUDE [Dimension1], [Dimension2]: Aggregation([Measure])

Use Case:
INCLUDE LOD expressions are useful when you want to perform calculations that consider the dimensions already present in the view along with additional ones. This allows you to refine your calculations based on a combination of dimensions.

Example:

  • Average Sales per Customer within Each Region:
    To calculate the average sales per customer within each region, considering both the region and customer dimensions, you use:

INCLUDE [Region], [Customer]: AVG([Sales])

This calculates the average sales for each customer within each region.

  • Total Profit by Category Including Subcategories:
    To get the total profit by category, including subcategories present in the view, you use:

INCLUDE [Category], [Subcategory]: SUM([Profit])

This aggregates profit at the category level, while also considering subcategories in the calculation.

3. EXCLUDE LOD Expression

Definition:
EXCLUDE LOD expressions aggregate data by removing specified dimensions from the calculation. The aggregation is performed at the level of detail present in the view minus the dimensions specified in the EXCLUDE expression.

Syntax:

EXCLUDE [Dimension1], [Dimension2]: Aggregation([Measure])

Use Case:
EXCLUDE LOD expressions are useful when you need to calculate a measure without considering certain dimensions present in the view. This helps in simplifying the analysis by excluding irrelevant dimensions.

Example:

  • Total Sales Ignoring Specific Region:
    To calculate the total sales across all regions, ignoring the region dimension in the view, you use:

EXCLUDE [Region]: SUM([Sales])

This computes the total sales irrespective of the specific region selected in the view.

  • Average Profit Excluding Subcategories:
    To find the average profit excluding the subcategory dimension, you use:

EXCLUDE [Subcategory]: AVG([Profit])

This calculates the average profit by excluding subcategories, providing a broader view of profit across categories.

Frequently Asked Questions

Q1: How do FIXED, INCLUDE, and EXCLUDE LOD expressions differ in their impact on data aggregation?

A1: FIXED LOD expressions aggregate data at a predefined level of detail regardless of the view’s dimensions. INCLUDE LOD expressions aggregate data considering the dimensions in the view plus additional ones. EXCLUDE LOD expressions aggregate data at the view’s level of detail minus the specified dimensions.

Q2: Can FIXED LOD expressions be affected by filters applied to the view?

A2: No, FIXED LOD expressions are not affected by filters applied to the view. They calculate values based on the fixed level of detail specified in the expression, irrespective of any filters or dimensions in the view.

Q3: How do INCLUDE LOD expressions handle filters applied to the view?

A3: INCLUDE LOD expressions respect the filters applied to the view. They calculate the aggregation based on the dimensions present in the view and any additional dimensions specified in the INCLUDE expression.

Q4: When should I use an EXCLUDE LOD expression?

A4: Use an EXCLUDE LOD expression when you need to calculate metrics by removing specific dimensions from the aggregation. This is useful for simplifying analyses by focusing on broader trends without the influence of certain dimensions.

Q5: Can I combine different types of LOD expressions in a single calculation?

A5: Yes, you can combine different types of LOD expressions in a single calculation by nesting them or using them in conjunction with other functions. This allows for complex and tailored calculations based on various levels of detail.

Q6: How do I troubleshoot issues with LOD expressions not providing expected results?

A6: To troubleshoot LOD expression issues:

  • Ensure the syntax and dimensions used are correct.
  • Verify that you are using the correct type of LOD expression for your needs.
  • Check for interactions with filters and other calculated fields that may impact the results.
  • Review Tableau’s data source and ensure that the underlying data is accurate and complete.