top of page
Writer's pictureBernard Kilonzo

Cohort analysis in Tableau


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

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.

calculated field computer customer first purchase

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

calculated field computing repeat customer purchase

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

calculated field computing customer second purchase

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

calculated field computing time lapsed between first and second customer purchase

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)

final view cohort analysis

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.

I hope this article was helpful to you. To receive more of the Tableau tips, kindly join our mailing list by subscribing below.

Thank you for reading.

Blog.png
bottom of page