This blog is inspired by blog: Top 15 Tableau LOD Expressions (Practical Examples).

Tableau LOD (Level of Detail) Expression is one of the most powerful tools to achieve amazing results in building dashboards. In this series of blogs, we will walk through 15 different use cases to demonstrate the usage of LOD expression.

Since this is a series blogs, please use the navigation below to jump to the one you need quickly:

Percentage of Total

I have to say there’re multiple methods of calculating the percentage of total with similar effort and LOD is only one of them.  In this example, we still connect to Sample-Superstore dataset, and we want to have a look at the sales performance for each Sub-category within its Category. So let’s start this task step by step:

1. We put two dimensions Category and Sub-category to Rows, and Sum of Sales to Columns. If we select the Marks card as Bar, we can get the result as below:

 

2. Let’s create a calculated field to calculate the sales of each category with LOD expression. In the script, we fixed the category level and sum the sales, so that even we set the viz level to Sub-category, this calculation still returns the same value.

3.Now let’s create another calculated field to show the percentage of total as shown in below image:

After that we drag this measure to label then we can mark the bars by the percentage of sales within category.

If we want to show the viz from Manufacturer level, we can click the “+” beside the Sub-Category cell and the label is the percentage of sales from one manufacturer within category.

 

I also create dashboard with related content and you can check in Tableau Public. Hope you like this blog and the dashboard.

Yi Gao
Author: Yi Gao

Yi has a master’s degree in data science from The University of Sydney and a background in engineering and manufacturing. She is passionate about finding insights from large and diverse datasets and applying them to real-world scenarios. In her previous role at Daimler China, she analysed vehicle usage data, provided recommendations and created dashboard for internal customers. In her spare time, she enjoys photography, especially of animals and her two sons, and cooking traditional Chinese food.