top of page
Search
• Bernard K

# Cohort analysis in Tableau

### What is cohort analysis?

Cohort analysis is a part of behavioral analytics that examines data from a large dataset and breaks it down into related groups. These smaller groups – or cohorts – share similar characteristics in a specified timeframe.

While exploring cohorts, it’s good to keep in mind that cohort has two major dimensions: a shared characteristic, and a defined timeframe.

For instance, a cohort could be defined as all customers who made their first purchase in a certain year or month.

### Cohort analysis example

(With this view, users can easily measure the return purchase of customers by cohort i.e., quarter of the year)

### How can you do cohort analysis in Tableau?

Using Sample-Superstore data, I will show you how to do cohort analysis. In this example, we will compute the return purchase by cohort (the proportion of customers who made their second purchase by cohort).

Step 1: Compute the 1st purchase date for each customer using the formula below.

Step 2: Compute the repeat purchase dates of each customer using the formula below.

(This computation returns nulls for cases where Order Date is the same as the 1st purchase date otherwise it returns the Order date).

Step 3: Compute the 2nd purchase date for each customer using the formula below.

(Note, 2nd purchase date is basically the minimum date of the repeat purchase).

Step 4: Compute the number of quarters to repeat purchase using the formula below.

Step 5: Build the view.

• Drag 1st purchase date to the rows shelf – choose level of detail as QUARTER (change the field from continuous to discrete).

• Drag Quarters to repeat purchase from measure area to dimension area.

• Drag Quarters to repeat purchase from dimension area to columns shelf.

• Select Square under marks card.

• Add Count distinct of Customer ID to color shelf.

• Add Count distinct of Customer ID to text shelf.

• Exclude the null values (basically customers who never came back) -optional.

• Show row grand totals to the left.

Add a table-calculation ‘Percent of Total’ on COUNTD(Customer ID).

(Note, this table calculation is computed across the table)

With this final view, you can track customer return purchases. For instance, you can see that – for customers acquired in 2017 Q1, 7.44% made their second purchase the same quarter while 16.53% made their second purchase after one quarter. While for customers acquired in 2019 Q2, 20.00% made their second purchase the same quarter while 50.00% of the customers made their second purchase after one quarter.