An important feature in Tableau is Level of Detail expressions (also known as LOD expressions), which are used to compute values at the data source level and the visualization level. They are useful as they provide more control over the level of granularity you want to compute.
In this guide, you will learn how to discern the three different types of LOD calculations in Tableau:
In general, include LOD expressions are used to perform computations at a more granular level, whereas exclude LOD expressions are used for computations at a less granular level. Fixed LOD expressions are used when the level of granularity remains independent of the computation.
This guide uses the sample superstore data source available in the Tableau repository.
A fixed LOD expression is used to compute a value using specified dimensions without reference to the dimensions in the view. Follow the instructions below to create a fixed LOD expression to check the profit generated by each product category. In the view, you will have both product and sub-product categories. However, the profit will be displayed with respect to each product category, not subcategories.
Click on the Analysis tab and select the Create Calculated Field option.
Profit
and Category
. This is shown below where the calculated field is named Fixed LOD - Profit Per Category
. Drag the Category
and Sub-Category
variables in the Rows shelf.
Even if you remove Category
from the view, the measure will be calculated based on the dimensions specified in the expression. This means that the changes in the view do not impact the aggregation of the measure Profit
, which is the feature of a fixed LOD expression.
An include LOD expression is used to compute values using specified dimensions in addition to the dimensions available in the view. Create an include LOD expression to visualize the average sales per product across different segments.
To begin, click on the Analysis tab and select the Create Calculated Field option.
Sales
and Product ID
. The calculation is shown below where the calculated field is named Include LOD: Avg Sales Per Product
. The calculation above expresses that at the granular Product ID
level, summation of Sales
will happen, while at the higher Segment
level, aggregation will happen at the average level.
Drag the Segment
variable into the Rows shelf and the calculated level of detail expression into the Columns shelf.
Segment
as highlighted below.Category
and Sub-Category
, in the view along with the Segment
variable. This will generate the following output. An exclude LOD expression is used to remove unwanted information from the data by creating an EXCLUDE
function to omit the dimension at which aggregation is not required.
Create an exclude LOD expression to visualize the annual sales for each segment and category with respect to total sales while omitting the order date.
Segment
and Category
into the Columns shelf and Order Date
into the Rows shelf. Click on the Analysis tab and select the Create Calculated Field option.
Sales
and Exclude: Order Date
, and click OK.Order Date
variable, and Measure Values into the label of the Marks card. This is shown below. In the above output, you can see that the values of the excluded expression are replicated. This is because the total value remains the same as the Order Date
is excluded. Also, this helps in comparing the contribution of individual year sales to the total sales across years.
In this guide, you learned how to create and discern the three different types of level of detail expressions—include, exclude, and fixed—in Tableau. This skill will help strengthen your descriptive as well as diagnostic analytics capabilities.
To learn more about visualization and data analysis using Tableau, please refer to the following guides: