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 INCLUDE LOD expressions, which let you specify dimensions to include in the calculation, regardless of what's in the view. Let's go through 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 INCLUDE 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 INCLUDE LOD Expression
Right-click anywhere on a blank area in the calculated field pane and select "Create Calculated Field."
To create an INCLUDE LOD expression, use the {INCLUDE} keyword followed by the dimension(s) you want to include in the calculation. For example, let's create an LOD expression to calculate the average profit per product category while including the Region dimension:
{INCLUDE [Region] : AVG([Profit])}
This expression tells Tableau to calculate the average profit per product category while including the Region dimension in the calculation.
Step 4: Use the INCLUDE LOD Expression in a Visualization
Drag the INCLUDE LOD expression you created (e.g., {INCLUDE [Region] : AVG([Profit])}) to the Rows shelf alongside the Category dimension.
This will create a visualization that shows the average profit per category, taking into account 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 Result
Analyze the visualization. You'll see that the average profit per category is calculated, considering the Region dimension. This means that the aggregation is done at the Region level, even though you're displaying data by category.
Step 7: Create Additional INCLUDE LOD Expression
You can create more INCLUDE LOD expressions as needed to perform calculations at various levels of detail in your data. For example, you could calculate the total sales per product category while including specific 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 INCLUDE Level of Detail (LOD) expression in Tableau to perform calculations that include specific dimensions, regardless of what's in the view. INCLUDE LOD expressions are valuable for performing calculations that consider additional dimensions beyond what's displayed in the visualization, providing flexibility and granularity in your analysis.
No comments:
Post a Comment