Customer analytics — RFM, retention, churn, cohorts, CLV and renewal
Measure and act on customer value and loyalty — segmentation by RFM, retention and churn rates, cohort retention, customer lifetime value and renewal rates.
This lesson builds on: KPI design, plan vs fact, variance and sales analysis, NumPy and pandas — the analysis workflow.
- Build RFM scores and actionable segments
- Calculate churn, retention and renewal rates with correct denominators
- Read cohort retention and estimate customer lifetime value with explicit assumptions
- Avoid common customer-metric mistakes
RFM analysis
| Definition | Segmenting customers by Recency (days since last purchase), Frequency (number of purchases) and Monetary value (total spend) |
| Purpose | Differentiate marketing: reward champions, win back lapsing customers, stop spending on lost ones |
| Data | Customer ID, transaction date, transaction value; a fixed analysis date |
| Formula | Score each dimension 1–5 by quintile (R: most recent = 5); combine into segments with explicit rules |
Worked example — segment sizes at Orion Retail (analysis date 2025-12-31):
WITH c AS (
SELECT o.customer_id,
julianday('2025-12-31') - julianday(MAX(o.order_date)) AS recency,
COUNT(DISTINCT o.order_id) AS frequency,
SUM(oi.quantity * oi.unit_price * (1 - oi.discount_pct)) AS monetary
FROM orders o JOIN order_items oi ON oi.order_id = o.order_id
WHERE o.status = 'completed' GROUP BY o.customer_id),
s AS (
SELECT *, NTILE(5) OVER (ORDER BY recency DESC) AS r,
NTILE(5) OVER (ORDER BY frequency) AS f,
NTILE(5) OVER (ORDER BY monetary) AS m FROM c)
SELECT CASE WHEN r >= 4 AND f >= 4 THEN 'Champions'
WHEN r >= 3 AND f >= 3 THEN 'Loyal'
WHEN r <= 2 AND f >= 3 THEN 'At risk'
WHEN r >= 4 AND f <= 2 THEN 'New / promising'
ELSE 'Hibernating' END AS segment,
COUNT(*) AS customers, ROUND(SUM(monetary)) AS revenue,
ROUND(100.0 * SUM(monetary) / (SELECT SUM(monetary) FROM s), 1) AS revenue_share_pct
FROM s GROUP BY segment ORDER BY revenue DESC;| segment | customers | revenue | revenue_share_pct |
|---|---|---|---|
| Champions | 895 | 1650153 | 53.6 |
| Loyal | 745 | 732823 | 23.8 |
| At risk | 444 | 405980 | 13.2 |
| Hibernating | 1161 | 236828 | 7.7 |
| New / promising | 229 | 54060 | 1.8 |
Interpretation. Champions and Loyal customers are a minority of customers but the majority of revenue; "At risk" customers used to buy often but have gone quiet — the highest-value win-back target. Decisions. Loyalty perks for Champions; personalised win-back for At risk; low-cost nurture for New; minimal spend on Hibernating. Common mistakes. Using "today" as analysis date (results drift); ignoring ties in NTILE; segment rules nobody can explain.
Churn, retention and renewal
| Metric | Formula | Denominator trap |
|---|---|---|
| Churn rate (period) | Customers lost during period ÷ customers at start of period | Don't include customers acquired during the period in the denominator |
| Retention rate | 1 − churn rate (same cohort) | Define "active" precisely (subscription vs purchase-based) |
| Renewal rate | Contracts renewed ÷ contracts due for renewal | Only contracts whose term ended can renew |
Worked example — telecom monthly churn (2025):
WITH active AS (SELECT month, COUNT(*) AS active FROM monthly_usage GROUP BY month),
lost AS (SELECT churn_month AS month, COUNT(*) AS churned FROM subscribers WHERE churned = 1 GROUP BY churn_month)
SELECT a.month, a.active, l.churned, ROUND(100.0 * l.churned / a.active, 2) AS churn_pct
FROM active a JOIN lost l ON l.month = a.month
WHERE a.month >= '2025-01' ORDER BY a.month LIMIT 6;| month | active | churned | churn_pct |
|---|---|---|---|
| 2025-01 | 5327 | 138 | 2.59 |
| 2025-02 | 5328 | 156 | 2.93 |
| 2025-03 | 5332 | 153 | 2.87 |
| 2025-04 | 5277 | 148 | 2.8 |
| 2025-05 | 5245 | 148 | 2.82 |
| 2025-06 | 5264 | 143 | 2.72 |
churn_month is the last billed month, so a subscriber churning in month M is active in M — the denominator is correct for "share of this month's base that leaves after this month". A 2% monthly churn compounds to about 1 − 0.98¹² ≈ 21.5% a year.
Renewal (insurance):
SELECT policy_type, COUNT(*) AS due, SUM(renewed) AS renewed, ROUND(100.0 * AVG(renewed), 1) AS renewal_pct
FROM policies WHERE end_date <= '2025-12-31' GROUP BY policy_type ORDER BY renewal_pct;| policy_type | due | renewed | renewal_pct |
|---|---|---|---|
| travel | 617 | 239 | 38.7 |
| auto | 567 | 445 | 78.5 |
| health | 623 | 493 | 79.1 |
| home | 598 | 477 | 79.8 |
Travel policies renew far less — often because trips are one-off. The decision may be to not judge travel by renewal at all but by repeat purchase.
Cohort analysis
Covered technically in SQL (Module 2). Business reading: plot each cohort's retention curve; compare at the same age (month 3 of the 2024-01 cohort vs month 3 of the 2025-01 cohort). Flattening curves = a loyal core; steepening curves for newer cohorts = deteriorating acquisition quality or onboarding.
Customer lifetime value (CLV)
Definition. The expected (discounted) gross margin a customer generates over their relationship. Simple formula (constant retention):
CLV = m × r ÷ (1 + d − r)
where m = annual margin per active customer, r = annual retention rate, d = annual discount rate (cost of capital). (Variant without margin in the first year: multiply by r; including year 1: m × (1 + d) ÷ (1 + d − r).)
Worked example. m = 120, r = 0.70, d = 0.10 → CLV = 120 × 0.70 ÷ (1.10 − 0.70) = 84 ÷ 0.40 = 210.
Interpretation & decisions. If acquiring a customer costs 150 (CAC), CLV/CAC = 1.4 — thin. Raising retention to 0.80 gives 120 × 0.8 ÷ 0.3 = 320 — retention is often the strongest lever. Common mistakes. Using revenue instead of margin; ignoring discounting; averaging CLV across very different segments; treating historical averages as guarantees.
Practice
In RFM, a customer with R = 1, F = 5, M = 5 (on 1–5 scales, 5 = best) is best described as:
At the start of March there were 8,000 subscribers; 400 new subscribers joined during March; 240 of the start-of-month subscribers left during March. What is March churn rate in %?
Annual margin per active customer m = 100, retention r = 0.8, discount rate d = 0.1. Using CLV = m × r ÷ (1 + d − r), what is CLV?
What is the correct denominator for an insurance renewal rate for Q3?
Summary
- RFM segments customers on recency, frequency, monetary value with a fixed analysis date and explicit rules.
- Churn/retention/renewal live or die by their denominators.
- Cohorts compare customers at the same age; CLV turns retention into money — use margin and discounting.