How to Do a Cohort Retention Analysis in Excel
By ExcelReady TeamUpdated 6 min read
The short answer
For a cohort analysis in Excel, give each customer a cohort (their signup month, =EOMONTH(B2,-1)+1) and give each activity row a month number since signup. Then build a grid with cohorts down the side and month numbers across the top, count with COUNTIFS, and divide each row by its cohort size to get retention percentages.
Key takeaways
- A cohort is a group that started in the same period, usually the signup month.
- =EOMONTH(date,-1)+1 turns any date into the first day of its month, which makes a clean cohort label.
- The month number is the gap between the cohort month and the activity month, from DATEDIF or YEAR and MONTH.
- COUNTIFS fills the grid; dividing by the cohort size turns counts into retention percentages.
- COUNTIFS counts rows, so remove duplicate customer-month rows first, or use a pivot table with Distinct Count.
On this page+
A cohort analysis in Excel groups customers by the month they signed up and tracks what share of each group is still active one, two and three months later. You need three things: a cohort month for each customer, a month number for each activity, and a COUNTIFS grid that turns them into a retention table. This guide builds one step by step, for analysts, marketers and anyone preparing for a data analyst job test.
What is a cohort retention table?#
A cohort is a group of people who started in the same period. A retention table puts one cohort on each row and the months since signup across the columns:
| Cohort | Size | Month 0 | Month 1 | Month 2 |
|---|---|---|---|---|
| Jan 2026 | 50 | 100% | 60% | 48% |
| Feb 2026 | 40 | 100% | 65% | |
| Mar 2026 | 60 | 100% |
These numbers are an example. Read across a row to see how one cohort fades over time: of the 50 January customers, 60% were active in their second month and 48% in their third. Read down a column to compare cohorts at the same age: February kept 65% in month 1, against January's 60%. The blank cells are months that haven't happened yet, which gives the table its triangle shape.
Decide first what "active" means for your business, such as made a purchase, logged in or renewed. The whole analysis depends on it.
The data you need#
You need two facts per customer: when they signed up and when they were active. The simplest layout is an activity table with one row per customer per active month:
| A | B | C | |
|---|---|---|---|
| 1 | Customer | Signup date | Activity date |
| 2 | C01 | 5 Jan 2026 | 12 Feb 2026 |
| 3 | C02 | 18 Jan 2026 | 3 Feb 2026 |
| 4 | C03 | 27 Jan 2026 | 20 Mar 2026 |
If your raw data is a log of every order or login, a customer can appear many times in one month. COUNTIFS counts rows, not people, so those duplicates would inflate the counts. Reduce the log to one row per customer per month first: add the activity month column below, then use Data > Remove Duplicates on the Customer and Activity month columns.
Step 1: Add cohort and month number columns#
Three helper columns turn raw dates into something you can count.
| Column | Header | Formula in row 2 | Result for C01 |
|---|---|---|---|
| D | Cohort | =EOMONTH(B2,-1)+1 | 1 Jan 2026 |
| E | Activity month | =EOMONTH(C2,-1)+1 | 1 Feb 2026 |
| F | Month number | =(YEAR(E2)-YEAR(D2))*12+MONTH(E2)-MONTH(D2) | 1 |
EOMONTH(B2,-1)returns the last day of the previous month, and+1moves to the first day of this month. Every January date becomes 1 Jan 2026, which makes a clean label for grouping. Format the column asmmm yyyy.- The month number counts whole calendar months between the two month starts. The YEAR and MONTH version works across year ends.
=DATEDIF(D2,E2,"m")gives the same result here, because both dates are first-of-month.
The EOMONTH function guide and our article on EDATE and EOMONTH explain the month functions. Month 0 is activity in the signup month itself.
Step 2: Build the cohort grid with COUNTIFS#
Put the cohort months down the side and the month numbers across the top, then count each pair. With cohorts in H3:H5 (1 Jan, 1 Feb and 1 Mar 2026) and month numbers 0, 1 and 2 in J2:L2, type this in J3:
=COUNTIFS($D$2:$D$500,$H3,$F$2:$F$500,J$2)Fill it across and down. Each cell counts the rows where the cohort matches the row label and the month number matches the column label. The mixed references do the work: $H3 always reads column H, and J$2 always reads row 2.
For the cohort size in I3, count customers by signup date from a customer list with one row per customer:
=COUNTIFS(Customers!$B$2:$B$200,">="&H3,Customers!$B$2:$B$200,"<="&EOMONTH(H3,0))This counts signups from the first to the last day of the cohort month. If your signup dates include times, use "<"&EOMONTH(H3,0)+1 for the upper limit instead, so late signups on the last day are included. The COUNTIFS function guide and the article on COUNTIFS and SUMIFS cover the criteria syntax.
Step 3: Turn counts into retention percentages#
Divide each count by the cohort size. In a second grid, type this and fill it across and down:
=IF(J3=0,"",J3/$I3)Format it as a percentage. The $ on column I keeps every cell dividing by its own row's cohort size. The IF leaves a blank instead of 0% for future months, which keeps the triangle readable. If a real month can have zero active customers, use a test on the date instead, such as =IF(EDATE($H3,J$2)>$B$1,"",J3/$I3) with the latest data month in B1.
Add a colour scale from Home > Conditional Formatting > Color Scales so high retention stands out at a glance.
The pivot table way#
A pivot table builds the same grid without COUNTIFS, once the helper columns exist:
- Select the activity table and choose Insert > PivotTable.
- Drag Cohort to Rows, Month number to Columns and Customer to Values (it shows Count of Customer).
- Right-click a value and choose Show Values As > % Of. Set the base field to Month number and the base item to 0.
Each cell now shows the share of that cohort's month 0 count. This uses month-0 activity as the cohort size, which matches only if every customer is active in their signup month.
If your table still has duplicate customer-month rows, tick Add this data to the Data Model when you create the pivot, then set the value field to Distinct Count. This option is in Excel for Windows and isn't available in every version. If you'd rather group the raw dates inside the pivot, see grouping dates by month in a pivot table, and our guide to Show Values As explains the % Of option.
How to read the results and common mistakes#
Look for three patterns: a steep drop from month 0 to month 1 (an onboarding problem), a curve that flattens (a loyal core), and newer cohorts that sit higher than older ones in the same column (an improvement).
Watch for these mistakes:
- Counting rows instead of customers. Duplicates push retention above 100%. De-duplicate first.
- Mixing calendar months and months since signup. The columns must be month numbers, not calendar months.
- Reading small cohorts too closely. A cohort of 8 customers can swing from 50% to 25% because of one person.
- Counting a partial month. If your data stops on 15 March, March looks worse than it is. Leave the current month out.
Cohort tables are a common case study in analyst interviews. The data analyst Excel test guide lists the related skills.
Practise it#
Try the exercise on this page to count one cell of a cohort table with COUNTIFS, EOMONTH and EDATE. Then practise COUNTIFS and SUMIFS in a live spreadsheet, practise EDATE and EOMONTH for month-based dates, and practise Show Values As in the pivot tables 2 lesson. Each lesson checks your work instantly.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
E1 holds the cohort month, 1 Jan 2026. Each row is one customer active in one month. In E3, count the customers who signed up in January 2026 and were active in February 2026. Use COUNTIFS with EOMONTH and EDATE.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | ||||||
| 3 | Month 1 | |||||
| 4 | ||||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 8 | ||||||
| 9 | ||||||
| 10 | ||||||
| 11 |
Tip: Signup date must be on or after E1 and on or before EOMONTH(E1,0). The active month must equal EDATE(E1,1), one month after the cohort.
Practise this in a lesson
Frequently asked questions
What is a cohort analysis?
It groups customers by when they started, usually their signup month, and tracks what share of each group is still active one, two or more months later. It shows whether newer customers stay longer than older ones.
How do I make a cohort table in Excel?
Add a cohort month and a month number to each activity row, list cohorts down the side and month numbers across the top, then fill the grid with =COUNTIFS(cohort_range,$H3,month_number_range,I$2). Divide by the cohort size for percentages.
How do I calculate retention rate in Excel?
Divide the number of customers still active in a month by the number who started in that cohort. For example, 30 active in month 1 out of a cohort of 50 is =30/50, or 60% retention.
Can I do a cohort analysis with a pivot table?
Yes. Put the cohort month in Rows, the month number in Columns and the customer in Values as a count. Then use Show Values As > % Of, with the month number as the base field and 0 as the base item.
Why are my retention numbers over 100%?
The activity data has more than one row per customer per month, so COUNTIFS counts some customers twice. Remove duplicate customer and month pairs first, or use Distinct Count in a pivot table.