KNOWLEDGE BASE

## Additional Cohort Analysis Example

Published: 10 Apr 2017
Last Modified Date: 16 Feb 2018

### Question

How to find customers who bought the most profitable products (per category) when the following information about the products must be true:
•  Products have been purchased at least 5 times between the following period:
• 18 months after their first purchase in 2014
• Last time they were purchased (in this example 2016)

Tableau Desktop

### Create the following Calculated fields

Create a calculated field for the first time a product was purchased.
• Select Analysis > Create Calculated Field...
• Create a Calculated Field called "First time Purchase" using the following formula:
`{FIXED [Product Name]: MIN([Order Date])}`
Create a calculated field for the last time a product was purchase.
• Select Analysis > Create Calculated Field...
• Create a Calculated Field called "Last time Purchase" using the following formula:
`{FIXED [Product Name]: MAX([Order Date])}`
Create a calculated field for the last time a product was purchase.
• Select Analysis > Create Calculated Field...
• Create a Calculated Field called "Months since first purchase" using the following formula:
`DATEDIFF("month",[First time product purchased],[Last time purchased])`

### Build the View

1. Drag "Category" and "Product Name" to Rows
• (Optional) Right-click Category and select Show Filter for easier navigation
2. Drag "Profit" to Columns.
3. Drag "Month since first purchase" to the Filter shelf and select At least > 18
4. Drag "First time Purchase" to the Filter shelf and select only 2014
5. Drag "Last time Purchase" to the Filter shelf and select only 2016
6. Drag "Sales" to the Filter shelf and select Count > At least > 5
7. Control and click on the "CNT(Sales)" in the Filter shelf and drag its copy to the Color shelf
8. (Optional) Add additional fields to Detail to add more information to the tooltip
To view the above steps in action, see the video below:
Note: the video has no sound.

### Additional Information

• About Cohort Analysis: Cohort Analysis is used to study the behavior or outcomes associated with a group of people over time. In Tableau you can perform cohort analyses and explore different groupings to understand consumer preferences, cause and effect relationships, and what is likely to happen to members of a particular cohort over time.
• Common use: In business, cohort analysis is most often used to study customer retention. A cohort is a group of customers or subjects that have a common characteristic. Cohorts can be determined by the date at which they joined a website or became a customer, by their age, their demographic, or any other attribute that could be used to group a set of individuals. It is then assumed that something about the cohort drives certain behavior over time.
• Popular Study: A popular subject area for cohort analysis is tracking user engagement on social-networking websites over the months following sign-up. A cohort can be based on the month and year in which a user joins the site. A metric could be the percent of users in cohort that visited the site each month after joining. For example, Facebook redesigned the look and feel of their site to make it more attractive and engaging for users. Growth of new users continued and even increased with the announcement. A cohort analysis would show whether the people who joined Facebook after the redesign found it easy and enjoyable to use.
• Connect to date- or time-based data: The data you connect to should consist of a date- or time-based list of events per individual. These events should record behavior you want to track—purchase date, sign-in date, message posting date, and so on. It can include more than one event type, and in that case you would need a unique row per individual, event, date, and time, along with any other attributes you need to form your cohorts.
• Define the Cohort: Determine how you will define a cohort. If the cohort is not represented as a dimension in the data, you can create calculated fields or sets.

Another example can be found in the following Knowledge Base article: Creating a Year Over Year YTD Comparison.
Did this article resolve the issue?