Cohort Analysis for Customer Retention with Spreadsheets and SQL
Group customers by when they started, follow each group over time and see what an average retention rate hides
Key takeaways
A cohort is a group of customers who share a starting event in the same period, such as their first order in March. Cohort analysis follows each group by its age, not by the calendar.
A triangular cohort table can be read three ways: rows show the life cycle of one group, columns compare groups at the same age and diagonals reveal events in a single calendar month.
A pooled retention rate mixes cohorts together. It can fall simply because a weak cohort became larger, even when no cohort got worse.
A cohort that behaves differently is a clue, not proof of cause. Metrics computed only on customers who are still active carry survivorship bias.
Observed retention curves are the raw material for customer lifetime value, but extending them with a simple curve fitted to the first few months usually forecasts badly.
Almost every subscription service, app and online store reports some version of the same number: the share of new customers who come back. It is one of the most watched figures in modern business, because acquiring a customer is expensive and the money is usually made on the second, third and tenth order. Yet the single retention figure on most dashboards is also one of the easiest to misread.
Consider a hypothetical drink-ordering app. Its dashboard shows that 43% of customers who placed a first order between January and May came back the following month, a figure that looks steady and unremarkable. Management relaxes. But when customers are split by the month of their first order, the picture changes completely. Customers acquired in April, the month of a big discount campaign, came back at only 29% after one month, while every other group held between 45% and 48%. The average had blended two very different stories into one ordinary-looking number.
The technique that exposes such hidden stories is cohort analysis: grouping customers by a shared starting point, such as the month of their first purchase, and tracking the behavior of each group period by period. Instead of treating the whole customer base as one block, the analyst follows the life cycle of each group and can see which group is unusual.
This article has five sections. Section 1 defines a cohort and distinguishes it from a segment. Section 2 shows how to read a triangular cohort table in three directions. Section 3 uses cohorts to diagnose why an aggregate metric moves. Section 4 warns about survivorship bias when reading cohorts. Section 5 connects cohorts to customer lifetime value and shows how to build a cohort table in a spreadsheet or in SQL.
1. What a cohort is
This section defines the cohort and explains how it differs from ordinary segmentation.
A cohort is a set of people or objects who share a starting event within the same time window: customers whose first purchase fell in March, users who installed an app in week 10, students who enrolled in the class of 2025. Cohort analysis tracks a metric, such as the share of customers still buying, spending or the number of orders, for each group according to the group's age, meaning the number of periods since the starting event. Age is the key idea. Two customers who joined in different months are compared at the same point in their relationship with the business, not at the same date on the calendar.
A cohort differs from a segment in its treatment of time. Segmentation divides customers by characteristics observed at one moment, such as age, region or a recency, frequency and monetary (RFM) score. A cohort divides customers by the moment they joined and then follows them as time passes. Cohort analysis is therefore both a segmentation technique and a way of tracking trends. Its place among the types of analytics depends on the purpose. Used to describe how well each group is retained, it is descriptive analytics. Used to explain why an aggregate metric moved, it is diagnostic analytics. Used to estimate how much future value each group will bring, it serves predictive analytics.
2. Reading a triangular cohort table
This section introduces the standard cohort table and the three directions in which it should be read.
The results of a cohort analysis are usually shown as a triangular table. Each row is a group of customers defined by the month of their first order, each column is the number of months since that order and each cell is the share of the group that ordered again in that month. Figure 1 is the cohort table for the drink-ordering app described above. The column on the left gives the size of each cohort; every percentage in the table is the number of customers from that cohort who ordered in the given month divided by that size. In the January cohort, for example, 940 of the 2,000 new customers ordered again in their second month, which gives 47%.
The table in Figure 1 is triangular because the later a cohort joined, the fewer months there are to observe it. The June cohort has only its first month; the January cohort has six. There are three ways to read the table and each answers a different question.
Reading along a row shows the life cycle of one cohort. The January cohort keeps 47% after one month and 38% after two, then declines more and more slowly to 28% after five months. This shape is very common: most customers who leave do so right after the first purchase, after which the curve flattens. Figure 2 draws each row as a line and makes the shape easy to see, along with the April line that sits well below the others from the very first month.

Reading down a column compares cohorts at the same age. In the Month 1 column, the cohorts hold between 45% and 48%, except April at 29%. This is the most important direction because it is the fair comparison: every cohort is viewed exactly one month after it joined, regardless of when that was.
Reading along a diagonal shows what happened to every cohort in the same calendar month. The cells on one diagonal, running from the lower left to the upper right, all fall in the same calendar month. In Figure 1, the cells for May are the January cohort in month 4 (30%), the February cohort in month 3 (32%), the March cohort in month 2 (39%) and the April cohort in month 1 (29%). If a whole diagonal were unusually low, the cause would probably be an event of that month, such as an app outage or a holiday period, rather than the quality of any one cohort. Here the other cells on the May diagonal are normal for their rows, which suggests that the April figure reflects something about the April customers themselves, not something that happened in May.
3. Using cohorts for diagnosis
The diagnostic power of cohorts lies in separating the effect of when customers joined from the general trend. This section shows what an aggregate number can hide and then discusses how to treat the clue a cohort provides.
3.1. The aggregate number blends the cohorts
Return to the 43% from the opening. The five cohorts from January to May brought in 10,000 new customers between them (Figure 1), and 4,287 of those customers ordered again in their second month. The pooled one-month return rate is therefore 4,287 / 10,000 = 42.9%, or about 43%. Because the cohorts are of similar size, the simple average of the five Month 1 cells, (47 + 45 + 48 + 29 + 46) / 5 = 43%, gives practically the same answer. The number does not lie, but it hides a cohort that behaves very differently. Table 1 shows what happens to the pooled figure when the size of the promotion cohort changes, with every other cohort held exactly as in Figure 1.
Table 1 shows that the pooled number can fall from about 43% to about 39% purely because a weak cohort was recruited in larger numbers, even though no cohort got worse and the April customers behave exactly as before. This is the same mechanism that drives Simpson's paradox: a change in the mix of groups changes the aggregate number. A manager who saw only the pooled rate falling would look for a decline in service quality that never happened; a manager who saw the cohort table would ask instead about the campaign that brought in the April customers.
3.2. From clue to conclusion
A cohort with clearly lower retention is a clue that the discount campaign attracted the wrong audience: people who came only for the low price and left when the discount ended. But a clue is not yet a conclusion. The April cohort differs from the others in several ways at once: the timing, the source of the customers and possibly even the products on sale that month. To know for certain that the promotion caused the low retention, you would need to compare, within the same month, customers who arrived through the promotion with customers who arrived without it. Better still is a controlled experiment that randomly offers the discount to some new customers and not to others, so that the two groups differ only in the offer. Cohorts show where to look; they do not by themselves prove a causal relationship.
4. Survivorship bias when reading cohorts
This section explains why any metric computed on customers who are still active must be read with care.
Cohorts need to be read with survivorship bias in mind. A metric computed on "active customers" in month six speaks only about the people who stayed. If the average order value of a cohort rises month after month, it does not necessarily mean that each customer is spending more. It may only mean that the customers who always spent a lot are the ones who stayed, while those who spent little have left. Figure 3 illustrates the mechanism.
In Figure 3, a cohort of 1,000 customers consists of 500 low spenders, who spend $8 per order, and 500 high spenders, who spend $24 per order. Nobody ever changes how much they spend. But low spenders leave faster, as Table 2 shows: after six months only 70 of them remain, while 320 high spenders are still ordering. The cohort's average order value therefore climbs from $16.0 to about $21.1.
A report written in a hurry would conclude that "the longer customers stay, the more they spend", which is completely false in this example. Every individual customer spends exactly what they spent on day one; only the composition of the group has changed. To separate the two explanations, compute the metric on a fixed set of customers, for example only those still ordering in month six, and trace their spending back through the earlier months. If the fixed group's spending is flat, the rise in the cohort average is survivorship, not growth in individual spending.
5. From cohorts to customer lifetime value
The retention curves of past cohorts are not only for looking back; they are a key input for estimating the future. This section connects cohorts to customer lifetime value and then shows how to build a cohort table.
5.1. Cohorts are the raw material of LTV
Customer lifetime value (LTV) depends heavily on retention. In the simplest model, where a customer who is still active stays for another period with a constant probability r, the expected number of periods a customer stays is 1 / (1 − r). Raising retention from 60% to 80% then doubles the expected lifetime, from 2.5 to 5 periods, and doubles LTV with it if the margin per period does not change. The retention curves observed in earlier cohorts are the data used to estimate r for new cohorts.
Fader and Hardie (2007) warn against a common mistake in doing this: extending the retention curve with a simple function, such as a linear, quadratic or exponential trend, that fits the first few months well. Such projections typically go badly wrong in later months, because the retention curve of a whole cohort flattens as the customers who were most likely to leave have already left. In other words, the very survivorship effect described in Section 4 changes the shape of the curve over time, and a model that forecasts retention has to account for it. Fader and Hardie propose a simple probability model that treats each customer as having their own chance of leaving and lets that mix of customers explain why observed retention rates rise with the age of a cohort.
At the management level, the benefit of better retention rarely shows up as an immediate jump in revenue. It shows up as more durable cohorts: customers acquired in a period come back more often, spend more and stay active longer (Knights, 2026). Tracking the Month 1 and Month 3 columns of the cohort table quarter by quarter is therefore a good way to judge whether customer care and loyalty efforts are working. If new cohorts start holding 50% after one month instead of 45%, the effort is paying off long before it is visible in annual revenue.
5.2. Building a cohort table
A cohort table can be built with a pivot table in Excel or Google Sheets, or with SQL; the finished table can then be shown as a heat map in a BI tool such as Data Studio or Power BI. In a spreadsheet, the process takes three steps. First, add a "first order month" column for each customer, using a function that returns the smallest order date for that customer ID (for example, MINIFS in Excel or Google Sheets). Second, add an "age" column with the number of months between the order date and the first order month. Third, put "first order month" in the rows, "age" in the columns and a distinct count of customer IDs in the values, then divide each cell by the cohort size in the age 0 column.
In SQL, the query below gives the same result from an orders table that contains a customer ID and an order date. It is written for DuckDB; other database systems name their date functions differently (PostgreSQL, for example, has no DATE_DIFF and computes the month difference from DATE_PART or AGE), but the structure carries over.
WITH firsts AS (
SELECT customer_id, DATE_TRUNC('month', MIN(order_date)) AS cohort_month
FROM orders GROUP BY customer_id
),
activity AS (
SELECT DISTINCT o.customer_id, f.cohort_month,
DATE_DIFF('month', f.cohort_month, DATE_TRUNC('month', o.order_date)) AS age
FROM orders o JOIN firsts f USING (customer_id)
)
SELECT cohort_month, age, COUNT(*) AS active_customers,
ROUND(100.0 * COUNT(*) /
FIRST_VALUE(COUNT(*)) OVER (PARTITION BY cohort_month ORDER BY age), 1) AS retention_pct
FROM activity
GROUP BY cohort_month, age
ORDER BY cohort_month, age;The first common table expression finds the first order month of each customer. The second turns every order into one row per customer and age, with DISTINCT so that a customer who ordered three times in a month counts once. The final SELECT counts active customers in each cohort and age and divides by the count at age 0, which the window function FIRST_VALUE picks out. The output is in long form: one row per pair of cohort and age. Pivoting it into a wide layout, with one row per cohort and one column per age, produces the triangle in Figure 1.
Conclusion
Cohort analysis answers a question that an average retention rate cannot: how different groups of customers move through their life cycle. A triangular cohort table has three directions of reading: along the rows to see the life cycle of one cohort, down the columns to compare cohorts at the same age and along the diagonals to detect an event in one calendar month. In the example, reading down the Month 1 column revealed that a cohort acquired through a promotion kept less than two-thirds of the level of the other cohorts (29% against 45% to 48%), something the pooled figure of 43% hid completely. The same pooled figure could drop to about 39% simply because the promotion brought in more of those customers.
Cohorts are powerful but must be read with care. They provide clues rather than proof of cause, and metrics computed on active customers always carry survivorship bias. Used well, cohorts bridge description, diagnosis and prediction: from knowing which customers stayed, to understanding why, to estimating how much they will bring.
References
Fader, P. S., & Hardie, B. G. S. (2007). How to project customer retention. Journal of Interactive Marketing, 21(1), 76–90. https://doi.org/10.1002/dir.20074
Knights, M. (2026). The future of shopping: Using digital, data and AI to win with customers. Kogan Page. https://www.koganpage.com/product/the-future-of-shopping-9781398627925




Discussion about this post