Power BI: Cohort Analysis Full Tutorial - Finance BI (2024)

In this article, you will learn how to run your Cohort Analysis in Power BI.

The cohort analysis is a powerful customer analysis: it segments customers based on when they first purchased a product. Specifically, it answers the questions:

  • Are newer customers coming back more often than older customers?
  • Are newer customers spending more than older customers?

These questions are key to understand if the company is going in the right direction, with newer customers coming back more often and spending more money.

If you are looking for a simpler analysis of new existing customers, check out my former article here.

Let's now take the questions one by one.

Are newer customers coming back more often than older customers?

Below is the classical chart of the cohort analysis. On left is the month of customer acquisition. The numbers represent the percentage of customers coming back after x months.

For example, 12% of the customers that first purchased in January 2018 came back to buy a month later, in February 2018.

Power BI: Cohort Analysis Full Tutorial - Finance BI (1)

From this chart, it looks like customers acquired from May 2019 are coming back more often. This is great news!

Nevertheless, the second semester of 2019 also has few 'empty spots' with zero customers coming back. Specifically, the new customers of April 2019 and June 2019 did not come back for 3 consecutive months (month 2 through month 4).

Looking at the totals at the bottom of the report, we see that on average 14% of customers buy again after 1 month, then only 8% in month 2. The remaining months are low, until a spike around month 10.

The spike in month 10 can be linked to a sales cycle: possibly the customers are replacing products after 10 months.

Let's move to the second question.

Are newer customers spending more than older customers?

From the table below, the average spend for new customers on month 0 (the first month) did not change across 2 years: it stays at about 65 dollars. There are however increases in average spend 2-3 months after acquisition, and 10 months after acquisition.

This chart highlights two factors:

  • we are not able to increase the average price spent by new customers in their first month.
  • we should look into the products purchased after 2-3 months and 10 months: identify if we can convince consumers to purchase these additional products earlier on.
Power BI: Cohort Analysis Full Tutorial - Finance BI (2)

With the goal of the cohort analysis clear, it's time to get our hands dirty and start with Power BI!

Load the sales data for the cohort analysis in Power BI

To follow along with the tutorial, download the sample sales data from here.

You can load it by going to Get Data, then clicking on Text/CSV. Below is what the sales table looks like.

Power BI: Cohort Analysis Full Tutorial - Finance BI (3)

Once the table is loaded, select it.

With the table selected, add a new column.

Power BI: Cohort Analysis Full Tutorial - Finance BI (5)

We add three columns this way. The first one is Month Year, and it will be used in the Cohort Analysis visualization.

The DAX formula is:

Month Year = FORMAT([date],"mmm yyyy")

The second and third columns are necessary for the cohort analysis calculations. Here they are:

Year Month Number = VALUE(FORMAT([date],"yyyymm"))

Year Month order = RANKX('Sales table',[Year Month Number],,ASC,Dense)

Once the three columns are added, the Sales table will look like this.

Power BI: Cohort Analysis Full Tutorial - Finance BI (6)

The last step for this table is to sort the Month Year column based on the Order column. Click on Month Year, then Sort by Column and finally on Year Month Order.

Power BI: Cohort Analysis Full Tutorial - Finance BI (7)

Create a table for the future months of the Cohort Analysis.

This is a simple table and will have rows for 'Month 0', 'Month 1', etc.

Click on New Table.

Power BI: Cohort Analysis Full Tutorial - Finance BI (8)

When the textbox appears, enter the following DAX formula:

Future months = GENERATESERIES(0, 12, 1)

The table will have 12 rows and look like this.

Power BI: Cohort Analysis Full Tutorial - Finance BI (9)

Similarly as before, click on New Column and add the following column:

Months = "Month "&[Value]

We have now the final table for the future months.

Power BI: Cohort Analysis Full Tutorial - Finance BI (10)

Done with creating tables! We can move our focus to adding the measures that we want to track.

Power BI: Cohort Analysis Full Tutorial - Finance BI (11)

Create a Power BI measure for the customer count (Cohort Analysis).

This first measure will count the customers coming, based on their acquisition month.

For example, out of the 32 customers who purchased in May 2018 for their first time, 9 purchased again one month later.

Power BI: Cohort Analysis Full Tutorial - Finance BI (12)

Here is the DAX formula for it:

New customers count =

var acquisitionMonth = SELECTEDVALUE('Sales table'[Year Month order])
var selectedFutureMonth = SELECTEDVALUE('Future months'[Value])

var currentCustomers = VALUES('Sales table'[customer])
var pastCustomers = CALCULATETABLE(VALUES('Sales table'[customer]),
ALL('Sales table'[Month Year],'Sales table'[Year Month Number])
, 'Sales table'[Year Month order]<acquisitionMonth)
var newCustomers = EXCEPT(currentCustomers,pastCustomers)

var customersFuturePeriods = CALCULATETABLE(VALUES('Sales table'[customer]),
ALL('Sales table'[Month Year],
'Sales table'[Year Month Number]),
'Sales table'[Year Month order] = acquisitionMonth+selectedFutureMonth )
var newCustomersBuyingInFuturePeriods = INTERSECT(newCustomers, customersFuturePeriods)

RETURN COUNTROWS(newCustomersBuyingInFuturePeriods)

There are three main parts to the formula.

The first part defines the variables acquisitionMonth and selectedFutureMonth. Using the example of the 9 customers purchasing again after one month, acquisitionMonth would be May 2018 and futureMonth would be 1.

The second section has the variables currentCustomers, pastCustomers, and newCustomers. This section finds the customers buying for the first time in May 2018.

Finally, the variable newCustomersBuyingInFuturePeriods identifies the customers acquired in May 2018 that also bought in June 2018.

This formula is quite complicated so my recommendation is to play around with it, load easy data to Power BI and see the result.

Create a formula for the percentage of new customers coming back

We want to build the table below.

Power BI: Cohort Analysis Full Tutorial - Finance BI (13)

If you don't need the total at the bottom, then you can use a simple formula:

New customers % no total =
[New customers count]
/
CALCULATE([New customers count],ALL('Future months'),'Future months'[Value]=0)

Using the same example as before, to calculate the percentage of customers acquired in May 2018 and coming back after 1 month, we divide 9 (customers coming back after 1 month) by 32 (customers acquired in May). The result is 28%.

This simpler formula, however, does not work for the total. To work on the total, we should use SUMX, which sums the values on different months. Below is the formula updated to work on the total.

New customers % =

var selectedFutureMonth = SELECTEDVALUE('Future months'[Value])
var maxRank = MAXX(ALL('Sales table'[Year Month order]),[Year Month order])
var months = VALUES('Sales table'[Year Month order])
var monthsFiltered = FILTER(months, [Year Month order]<=maxRank-selectedFutureMonth)

RETURN SUMX(monthsFiltered,
[New customers count])
/
SUMX(monthsFiltered,
CALCULATE([New customers count],ALL('Future months'),'Future months'[Value]=0))

Let's move to the last formula: the new customers average spend.

Create a Power BI formula for the average spend of customers (Cohort Analysis)

This last formula shows us how much returning customer spend. It allows us to create the table below.

Power BI: Cohort Analysis Full Tutorial - Finance BI (14)

The formula is similar to the first formula for the customer count, except for the last part.

New customers average spend =

var acquisitionMonth = SELECTEDVALUE('Sales table'[Year Month order])
var selectedFutureMonth = SELECTEDVALUE('Future months'[Value])

var currentCustomers = VALUES('Sales table'[customer])
var pastCustomers = CALCULATETABLE(VALUES('Sales table'[customer]),
ALL('Sales table'[Month Year],'Sales table'[Year Month Number])
, 'Sales table'[Year Month order]<acquisitionMonth)
var newCustomers = EXCEPT(currentCustomers,pastCustomers)

var customersFuturePeriods = CALCULATETABLE(VALUES('Sales table'[customer]),
ALL('Sales table'[Month Year],'Sales table'[Year Month Number]),
'Sales table'[Year Month order] = acquisitionMonth+selectedFutureMonth )
var newCustomersBuyingInFuturePeriods = INTERSECT(newCustomers, customersFuturePeriods)

RETURN
CALCULATE(SUM('Sales table'[sales]),
ALL('Sales table'[Month Year],'Sales table'[Year Month Number]),
'Sales table'[Year Month order] = acquisitionMonth+selectedFutureMonth,
'Sales table'[customer] IN newCustomersBuyingInFuturePeriods)
/
COUNTROWS(newCustomersBuyingInFuturePeriods)

The last part (starting from RETURN) is different: there is a CALCULATE divided by a COUNTROWS.

The COUNTROWS is the same as before: it counts the number of customers returning after x months. The CALCULATE, on the other hand, finds how much these customers spend.

With all the measures created, add a Matrix report and you have your Cohort Analysis.

Power BI: Cohort Analysis Full Tutorial - Finance BI (15)

That's it! You can create a powerful Cohort Analysis in Power BI. If you have questions, do not hesitate to add comments below.

Enjoyed the article? Subscribe to the newsletter and download the Power BI of the article for free.

    Power BI: Cohort Analysis Full Tutorial - Finance BI (2024)

    FAQs

    How do you do a cohort analysis in power bi? ›

    Create a Power BI measure for the customer count (Cohort Analysis). This first measure will count the customers coming, based on their acquisition month. For example, out of the 32 customers who purchased in May 2018 for their first time, 9 purchased again one month later. There are three main parts to the formula.

    How do you do cohort analysis in Excel? ›

    How to build a cohort analysis in Excel
    1. Import your data. Start by importing customer information. ...
    2. Create cohorts. ...
    3. Create a "Months" column. ...
    4. Create a PivotTable. ...
    5. Create a Retention Rates sheet. ...
    6. Calculate the number of customers you retain each month. ...
    7. Calculate retention rates.
    17 Mar 2022

    How do you calculate retention in power bi? ›

    It is doing 780 divided by 793. When i'm taking a row card and plotting my retention. Rate it is

    What are the two types of cohort analysis? ›

    There are two types of cohort studies: prospective and retrospective (or historical) cohorts. Prospective studies follow a cohort into the future for a health outcome, while retrospective studies trace the cohort back in time for exposure information after the outcome has occurred.

    How many types of cohort analysis are there? ›

    There are two types of cohort analysis: Acquisition cohorts. Behavioral cohorts.

    What is cohort analysis in finance? ›

    Cohort analysis is part of behavioral analytics that helps businesses assess consumer behavior based on a few common criteria and accordingly decide and introduce their products and services in the market. The groups are related, have a defined time frame, and they share a common statistical trait.

    How do you calculate cohort retention in SQL? ›

    The retention rate is calculated by counting the number of users who return on a regular basis, such as every week or month, and grouping them by the week they signed up.

    What is cohort retention? ›

    Cohort Retention is an important measurement that reflects a business's health. Retention metric is often analyzed across groups of customers that share some common properties, hence the name Cohort Retention Analysis.

    What is SQL for data analysis? ›

    What is SQL? SQL (Structured Query Language) is a programming language designed for managing data in a relational database. It's been around since the 1970s and is the most common method of accessing data in databases today. SQL has a variety of functions that allow its users to read, manipulate, and change data.

    Does Excel use cohort analysis? ›

    Cohort Analysis Excel Step 1: Understand and Clean the Data Set. Cohort Analysis Excel Step 2: Add New Columns to the Data. Cohort Analysis Excel Step 3: Data Visualization. Cohort Analysis Excel Step 4: Perform Cohort Churn Analysis.

    What is an example of cohort? ›

    The term “cohort” refers to a group of people who have been included in a study by an event that is based on the definition decided by the researcher. For example, a cohort of people born in Mumbai in the year 1980. This will be called a “birth cohort.” Another example of the cohort will be people who smoke.

    What is a cohort analysis used for? ›

    Cohort analysis is a tool to measure user engagement over time. It helps to know whether user engagement is actually getting better over time or is only appearing to improve because of growth.

    What is Lod in tableau with example? ›

    Level of Detail (LOD) expressions are used to run complex queries involving many dimensions at the data source level instead of bringing all the data to Tableau interface. A simple example is adding dimension to an already calculated aggregate value.

    › blog › cohort-analysis ›

    Long-term success for app developers does not mean only getting someone to download their app, but also getting them to make repeat visits. To get to the must-h...
    Cohort analysis is a study that focuses on the activities of a particular cohort. If we were to calculate the average income of these students over the course o...
    Businesses can also use such insights to come up with successful growth strategies. They can learn more about their Customer Retention Rate as well as the Avera...

    What is cohort analysis in analytics? ›

    Cohort analysis helps you understand the behavior of component groups of users apart from your user population as a whole. Examples of how you can use cohort analysis include: Examine individual cohorts to gauge response to short-term marketing efforts like single-day email campaigns.

    How do you compare cohorts? ›

    Within the cohort definition or i can use the legend by clicking the up arrow. And then hovering

    Why cohort analysis is used? ›

    A cohort analysis table is used to visually display cohort data in order to help analysts compare different groups of users at the same stage in their lifecycle, and to see the long-term relationship between the characteristics of a given user group.

    What is cohort and cohort analysis? ›

    Cohort Analysis is a form of behavioral analytics that takes data from a given subset, such as a SaaS business, game, or e-commerce platform, and groups it into related groups rather than looking at the data as one unit. The groupings are referred to as cohorts. They share similar characteristics such as time and size.

    › watch ›

    Hi All, you can download this template from below link.https://www.ecanalyticsconsulting.com/cohort-analysis-in-excel/
    Last week, I asked our Analytics for Humans community on Facebook for a few suggestions on topics they'd like to learn more about. Based on the responses, p...

    Top Articles
    Latest Posts
    Article information

    Author: Domingo Moore

    Last Updated:

    Views: 5691

    Rating: 4.2 / 5 (73 voted)

    Reviews: 88% of readers found this page helpful

    Author information

    Name: Domingo Moore

    Birthday: 1997-05-20

    Address: 6485 Kohler Route, Antonioton, VT 77375-0299

    Phone: +3213869077934

    Job: Sales Analyst

    Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

    Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.