In Tableau, LOD (Level of Detail) expressions allow you to control the granularity of calculations, whether more or less detailed than the view. The Sample Superstore dataset is perfect for showcasing examples of LOD expressions. Here are some examples of different types of LOD expressions in Tableau:
1. FIXED LOD
The FIXED
expression allows you to calculate a value at a specific level of granularity, regardless of what is shown in the view.
Example: Calculate Total Sales per Customer
{FIXED [Customer Name] : SUM([Sales])}
- Description: This expression calculates the total sales for each customer, regardless of what dimensions are in the current view.
Example: Calculate Average Discount per Region
{FIXED [Region] : AVG([Discount])}
- Description: This will return the average discount given in each region, regardless of the level of detail in the view.
2. INCLUDE LOD
The INCLUDE
expression adds dimensions to the view that are not already included, allowing you to calculate values at a more detailed level.
Example: Include Sales per Product Category and Sub-Category
{INCLUDE [Category], [Sub-Category] : SUM([Sales])}
- Description: This includes both
Category
andSub-Category
in the view and sums the sales at this finer level of granularity.
3. EXCLUDE LOD
The EXCLUDE
expression removes dimensions from the view, allowing you to calculate values at a less detailed level.
Example: Exclude Region to Calculate Total Sales Across All Regions
{EXCLUDE [Region] : SUM([Sales])}
- Description: This will sum the sales for all regions, even if
Region
is in the view, effectively ignoring theRegion
field in the calculation.
Example: Exclude Order Date to Calculate Total Sales by Segment
{EXCLUDE [Order Date] : SUM([Sales])}
- Description: If
Order Date
is in the view, this expression will exclude it and instead calculate the total sales by segment or other dimensions in the view.
Combining LOD Expressions with Other Calculations
You can combine LOD expressions with other calculations to create powerful analytics.
Example: Percentage of Sales by Customer vs. Total Sales
SUM([Sales]) / {FIXED : SUM([Sales])}
- Description: This calculation gives the percentage of sales made by each customer compared to the overall sales in the dataset.
These LOD expressions help control the granularity of your calculations in the Sample Superstore dataset, providing a wide range of analytical possibilities.