How to Use Tableau Level of Detail (LOD) Expressions - An Example

The introduction of Level of Detail (LOD) Expressions in Tableau 9.0 made it a lot easier for Tableau Desktop users to look at data in different ways. Once you know how to use the INCLUDE, EXCLUDE and FIXED expressions, you will find that you can easily perform some powerful data analysis.

Per the Tableau website, “LOD Expressions allow you to determine the levels of detail (i.e., the dimensions) used in a calculation without actually dropping those dimensions into the visualization. You can define the level of detail at which a calculation should be performed, independently of the Viz LOD.” If you read this and think “Huh?,” you are not alone. I am going to share a real-life example to help explain what this means. I recently assisted a client who was looking at data for their contact center. We used the INCLUDE expression to come up with the information he wanted.

Before I get into this specific example, it’s important to note that you need to understand how your data is structured in order to use LOD Expressions effectively. How your data is structured will dictate how and when you need to use the different LOD Expressions. You will see why as you read on.

Desired result:  Total call time for each contact center agent (i.e., one row per agent)

LOD Expression:  INCLUDE

 

The client contacted me because he set up a calculation and was getting some unwanted results. He was experimenting with the expression SUM(Call Duration) and the dimensions Contact Center Agent Name, Call ID, Call Start Central and Call End Central. This calculation returned a row with the call time for each Call ID. In some cases, the call time was too high. I suggested we take a closer look at the source data.


In Tableau Desktop, you can view data details by right-clicking on a data point and selecting View Data. In this case, we looked at the details behind the 208 seconds for Call ID 114000011926.

tableau level of detail expressions1
 
tableau level of detail expressions2

As you can see, there are two records for Call ID 114000011926. Why two records? Perhaps it was a conference call or the call was transferred from one person to another. Even though the call was 104 seconds in length, the calculation Sum(Call Duration) added the call time for both records to arrive at a total of 208.

 

To resolve this problem, he could use the calculation Max(Call Duration) to count the call time just once for each Call ID.

tableau level of detail expressions3

This still returns a row for each Call ID. What he really wanted was one row for each agent showing the total time for all Call IDs. He could remove the Call ID, Call Start Central and Call End Central dimensions from the grain of the view, but the calculation would no longer include the necessary Call ID level of detail.

tableau level of detail expressions4

 
To resolve this problem, we used the LOD Expression INCLUDE as follows:

 
    
{ INCLUDE [Call ID] : Max([Call Duration])}

tableau level of detail expressions5

This calculation forces Call ID to be included in the grain or level of detail of the Tableau view. The level of detail is the smallest element of data allowed by the combination of dimensions and measures. The INCLUDE expression goes one step beyond the dimensions and measures dragged into the view and forces Call Duration to consider an element of data even more granular.

 
The following is an illustration of the source data, calculations and results.


tableau level of detail expressions6

Give LOD Expressions a try. You will be thrilled with how these expand your ability to analyze data! For more information, go to the Tableau website or contact me (Benjamin Barlow) at barlowb@svaconsulting.com.


Benjamin Barlow
Business Analyst
By SVA | Jan 27, 2017

About SVA Consulting

Since 1992, hundreds of businesses, agencies and organizations have turned to SVA Consulting to solve business problems. Whether it's managing financial information, tracking inventory, analyzing sales data, job costing or any of hundreds of other business processes, our consultants take the time to listen and learn about the challenges you face, understand your business objectives, and present a comprehensive plan, timeline, and training for achieving your goals.

Fill out the form below if you would like more information on this topic or the services SVA Consulting provides.