Level of Detail (LOD) Expressions in Tableau allow you to perform calculations at different levels of granularity within your data without affecting the overall aggregation. In this tutorial, we'll focus on EXCLUDE LOD expressions, which allow you to exclude dimensions from the calculation, regardless of what's in the view. Here's a step-by-step tutorial with examples:
Example Data: We'll continue using the same dataset of sales transactions with columns: Order ID, Product, Category, Sales, Profit, and Region.
Tutorial: Using EXCLUDE Level of Detail (LOD) Expressions in Tableau
Step 1: Open Tableau and Connect to Your Data
Launch Tableau and connect to your dataset (e.g., Excel, CSV, database).
Step 2: Create a Simple Visualization
Drag the Category dimension to Rows and the Sales measure to Columns to create a bar chart showing total sales by category.
Step 3: Create an EXCLUDE LOD Expression
Right-click anywhere on a blank area in the calculated field pane and select "Create Calculated Field."
To create an EXCLUDE LOD expression, use the {EXCLUDE} keyword followed by the dimension(s) you want to exclude from the calculation. For example, let's create an LOD expression to calculate the average profit per product category while excluding the Region dimension:
{EXCLUDE [Region] : AVG([Profit])}
This expression tells Tableau to calculate the average profit per product category while excluding the Region dimension from the calculation.
Step 4: Use the EXCLUDE LOD Expression in a Visualization
Drag the EXCLUDE LOD expression you created (e.g., {EXCLUDE [Region] : AVG([Profit])}) to the Rows shelf alongside the Category dimension.
This will create a visualization that shows the average profit per category, excluding the Region dimension.
Step 5: Customize Your Visualization
Customize the visualization as needed by adding labels, colors, or other dimensions to enhance the presentation of the data.
Step 6: Understand the Results
Analyze the visualization. You'll see that the average profit per category is calculated while excluding the Region dimension. This means that the aggregation is done at the category level without considering the Region dimension.
Step 7: Create Additional EXCLUDE LOD Expressions
You can create more EXCLUDE LOD expressions as needed to perform calculations at various levels of detail in your data while excluding specific dimensions. For example, you could calculate the total sales per product category while excluding certain customer segments.
Step 8: Save and Share Your Workbook
Once you're satisfied with your visualization, save your Tableau workbook and share it with others as needed.
That's it! You've created an EXCLUDE Level of Detail (LOD) expression in Tableau to perform calculations that exclude specific dimensions from the calculation, regardless of what's displayed in the view. EXCLUDE LOD expressions are useful for fine-tuning your analysis by excluding certain dimensions while aggregating data, providing flexibility and control in your calculations.
