A common analysis task in Tableau is to describe and identify include level of detail (LOD) expressions, which compute values using specified dimensions in addition to the dimensions available in the view. Include LOD expressions give more control over the level of granularity you want to compute. In this guide, you will learn how to describe and identify include LOD calculations in Tableau.
To construct the include level of detail expression, you'll need a dimension, against which you will aggregate the view information, and the measure that’ll be aggregated.
This guide will use the Sample Superstore data source available in the Tableau repository. There are three sheets,
Return, that have been joined to fetch the data.
In this guide, you’ll walk through two scenarios.
In the first scenario, say you want to visualize the average sales per product across different segments. To begin, click on the Analysis tab and select Create Calculated Field option.
The next step is to write the Include LOD expression to show the average sales per product category. To do this, you’ll use the variables
Product ID. The calculation is shown below where the calculated field is named as
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.
The next step is to drag the
Segment variable into the Rows shelf and the calculated level of detail expression into the Columns shelf.
Next, turn the Text label on and sort in descending order. This will be fixed for each
Segment as highlighted below.
It is also possible to add more variables like
Sub-Category in the view along with the
Segment variable. This will generate the following output.
In the second scenario, you will calculate and visualize the average profit per customer and state. To begin, drag the variable
State into the Marks pane and place it into the Detail option as shown below. This will plot the latitude and longitude of the records, resulting in a map with
State as the level of detail.
The output above displays a world map, but no states are highlighted yet. Also, at the bottom right, it is displaying 49 unknown. Clicking on this message will generate a pop-up window.
Click on the Edit Locations… option, which will open another window. Note that you can also directly access the map options using the top menu of the Tableau desktop.
The output above shows that the Country/Region option is set to India, which is why it is not able to detect U.S. states. To change it, click on the dropdown options available.
Select the None option, or make the correct choice using the From field drilldown. This will plot all the states in the United States.
You have created the map, and the next step is to create a calculated field, as shown below.
The next step is to write the Include LOD expression to show the average profit per customer. The calculation is shown below, where the calculated field is named
Include LOD: Avg Profit Per Customer.
The next step is to drag the calculated level of detail expression into the Label and Color shelves of the Marks pane.
It’s also possible to include more dimensions in the view by simply dragging the dimensions into the Detail tab of the Marks pane. Add the variables
Sub-Category to demonstrate this.
In this guide, you learned how to create an include LOD expression in Tableau and applied this knowledge in two different scenarios. This skill will strengthen your business intelligence and visualization capabilities.
To learn more about visualization and data analysis using Tableau, please refer to the following guides: