Level of Detail (LOD) expressions in Tableau are a powerful tool for performing calculations that aggregate data at different levels of granularity. They allow you to perform calculations that are not possible with standard aggregations or calculations in Tableau.
There are three types of LOD expressions in Tableau:
- Fixed LOD expressions: Fixed LOD expressions allow you to define a specific level of detail for a calculation, regardless of the view or filters applied to the data. For example, a fixed LOD expression could calculate the total sales for a specific product category, regardless of the other dimensions or filters in the view.
Syntax: {FIXED [dimension1], [dimension2], … : [expression]}
Example: {FIXED [Product Category]: SUM([Sales])}
This expression calculates the total sales for each product category, regardless of any other dimensions or filters in the view.
- Include LOD expressions: Include LOD expressions allow you to calculate a value for a specific dimension, while still considering the overall view. This allows you to include a specific dimension in the calculation, even if it’s not part of the view.
Syntax: {INCLUDE [dimension] : [expression]}
Example: {INCLUDE [Product Category] : SUM([Sales])}
This expression calculates the total sales for each product category, but still considers the overall view, including any other dimensions or filters.
- Exclude LOD expressions: Exclude LOD expressions allow you to calculate a value for the overall view, but exclude a specific dimension. This allows you to exclude a specific dimension from the calculation, even if it’s part of the view.
Syntax: {EXCLUDE [dimension] : [expression]}
Example: {EXCLUDE [Product Category] : SUM([Sales])}
This expression calculates the total sales for the overall view, but excludes the sales for each product category.
LOD expressions can be used in a variety of ways in Tableau, such as creating custom aggregations, finding the difference between two measures, or filtering data based on a specific level of detail. They are especially useful when working with data at multiple levels of granularity, such as when analyzing sales data by product category, region, and time period.