The level of detail calculations (LOD) enable you to tell Tableau Public at exactly which dimensional level you would like to aggregate without having to place that dimension on the visualization. Additionally, you can include or exclude dimensions in the calculations and create calculations that include all the underlying data.
The following are the three types of LOD calculations:
LOD has a big caveat. While you can perform table calculations on them and create aggregations and functions within them, you cannot include table calculations in them.
Each LOD calculation has the following three features that are different from those that we have discussed before:
Note that the entire expression is enclosed in curly braces, as shown in the following screenshot. The LOD calculations are the only instances in Tableau Public where you will use curly braces:
This field provides us with the unique number of countries in each region, even though 80 percent of these countries are filtered out. This provides great context.
In the following example, we will discuss:
This visualization shows us the bottom 20 percent of the 53 countries in Africa in the data set. It would be even more helpful to know what the overall access to improved water sources is in each region and not just by country.
The following are a few issues that we need to overcome with virtualization:
In the following example, we will show you how to solve some problem by using an INCLUDE LOD calculation nested within a FIXED LOD calculation, and each will be aggregated. This is an issue that most people have had to solve by using data sources with different levels of aggregation, which takes a lot of time to develop and render in Tableau Public.
Create a new field within the World Development Indicators data source and name it Population with Access to Improved Water. It's kind of a long name, but we want to ensure that no one misunderstands the metric.
So, here's our approach to calculating the overall percentage of each region with access to clean water:
Rationale: For every country, we need to know the total population that has access to the sources of clean water. We have the percentage of the population. So, we need to multiply the maximum percentage with the total population to get the number of people who have access to clean water.
INCLUDE
function at the Country Name level and then use the MAX
aggregations. The granularity of the data is at the Year level. We are not including Year, because that would produce the population at the Country Name and Year level. We just want the total population of each country, as shown in the following screenshot:This is a long field, but it accomplishes what has been difficult before, namely aggregating at multiple dimensional levels in one calculation without duplications, and aggregating records that are not a part of the visualization.
Add this field to the Rows shelf of the previous bar chart, turn it into a discrete field, and drag it to the left of Country Name, just as we did for Country Count.
Also, right-click on the new calculated field, click on Default Properties, and then select Format so that we can set the number format as a percentage.
Here's the finished product. Only 69 percent of the people in Africa have access to clean drinking water: