Select Page
`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.

### Cohort analysis

In this blog, we will demonstrate a simple example of customer cohort analysis with Tableau LOD.

In this example, our goal is:  if longer tenured customers contribute a larger percentage of sales, we could do the following. We will use Superstore dataset to this example and the steps are as followed:

1. Let’s create the Customer Cohort: to achieve this, we need to think about how to define the customer cohort. In this example, we separate the cohort based on the first time a customer made an order. So we need to create a calculated field named Customer Cohort with the script shown in below image:

2.Viz structure construction: we need to construct the basic structure of the visualization we want to achieve. We can drag Order Date to Columns (discrete year of “Order Date” field) and the total of sales (SUM of “Sales” field) to rows.

3. Color the Cohort: if we want to know for each year of the order date, how much sales is from each customer cohort, we could color the bar chart by the calculated field we created, which is “Customer Cohort”. The set-up in Tableau is as shown in below image:

4. Analyze the proportion: we want to further know the proportion of the sales each customer cohort contributed to, so we could add another set of bars to visualize the percentage. Let’s duplicate the sheet and add “Percentage of Total” to table calculation. The setting is shown in below image.
5. Finish the work in a dashboard: finally let’s put the two sheet we make together and format a little bit to add some readability and pretty to it.

An example dashboard is published in Tableau public as well:

##### 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.