How to do RFM Analysis in Excel — Segment Customers by Value from Scratch
RFM — Recency, Frequency, Monetary — is the most actionable customer segmentation model you can build without machine learning. It tells you exactly which customers are Champions (buy often, buy recently, spend the most), which are At Risk (were Champions but have gone quiet), and which are Lost. This tutorial walks through building the complete model in Excel: DATEDIF for recency, COUNTIFS for frequency, SUMIFS for monetary value, PERCENTILE-based 1–5 scoring, and segment label assignment. No VBA, no add-ins, no paid tools.
TL;DR
Create an RFM sheet with one row per customer. Calculate Recency as days since last purchase using DATEDIF(MAXIFS(...),TODAY(),"D"). Calculate Frequency as order count using COUNTIFS. Calculate Monetary as total spend using SUMIFS. Score each dimension 1–5 using PERCENTILE-based thresholds in an IFS formula — note that for Recency, lower days = better = score 5 (reverse direction). Concatenate scores to an RFM string (e.g. “555”) and map to segment names. The whole process takes about 45 minutes on a clean transaction file.
Contents
- Step 1 — Prepare transaction data as an Excel Table
- Step 2 — Build the customer list and calculate Recency
- Step 3 — Calculate Frequency with COUNTIFS
- Step 4 — Calculate Monetary value with SUMIFS
- Step 5 — Score 1–5 using PERCENTILE thresholds
- Step 6 — Assign segment labels and build summary output
- Frequently asked questions
Step 1 Prepare your transaction data as an Excel Table
RFM analysis starts with a transaction-level log — one row per transaction (or order), not one row per customer. If you already have aggregated data you’ll need to reconstruct the raw transactions, or adapt the Recency step to use last-transaction-date directly.
Required columns
| CustomerID | OrderDate | Revenue | (Optional) |
|---|---|---|---|
| C001 | 2026-04-12 | 340.00 | Channel, Product, Region |
| C002 | 2026-03-28 | 120.50 | — |
| C001 | 2026-05-01 | 290.00 | — |
CustomerID must be a consistent identifier — the same string or number for the same customer across all rows. OrderDate must contain real Excel date values, not text strings. Revenue must be a number (no £ symbols, no commas as thousands separators in the raw cell value).
Convert the range to an Excel Table: click inside the data and press Ctrl+T. On the Table Design tab, rename it to Transactions. This ensures all MAXIFS, COUNTIFS, and SUMIFS formulas auto-expand when you add new transaction rows in future months.
Step 2 Build the customer list and calculate Recency
Add a new worksheet called RFM. Column A will hold unique CustomerIDs. If you’re on Microsoft 365 you can use =SORT(UNIQUE(Transactions[CustomerID])) to auto-populate the list. For Excel 2016/2019, remove duplicates: copy the CustomerID column, paste into the RFM sheet, then Data → Remove Duplicates.
Recency: days since last purchase
In column B (Recency), enter this formula for the first customer row and drag down:
This formula does three things: MAXIFS finds the most recent OrderDate for this CustomerID; DATEDIF(..., TODAY(), "D") calculates the number of complete days between that date and today. A lower Recency value means the customer purchased more recently — which is better. Keep this in mind when scoring.
Common issue — MAXIFS returns 0: this usually means the CustomerID in column A doesn’t exactly match the Transactions table. Check for trailing spaces (use TRIM(A2)), text vs number mismatch, or case differences. A quick check: enter =COUNTIFS(Transactions[CustomerID], A2) — if it returns 0, there is no matching row.
Step 3 Calculate Frequency with COUNTIFS
Frequency measures how many times a customer has transacted. In column C (Frequency):
This counts the total number of rows in the Transactions table where CustomerID matches. If one physical order can span multiple rows (e.g. one row per line item), you need to count distinct OrderIDs instead:
This SUMPRODUCT formula counts distinct OrderIDs for the customer, regardless of how many line items each order contains. It’s more complex but gives you a genuine “number of purchases” count rather than a line-item count.
Frequency within a date window
If you only want to score activity within the last 12 months (a common approach to focus on active customers only), add a date filter:
Step 4 Calculate Monetary value with SUMIFS
Monetary is the total revenue generated by the customer. In column D (Monetary):
For a time-windowed monetary value (e.g. only last 12 months to match the frequency window):
Average Order Value as a secondary metric
Add column E for Average Order Value (AOV), which is a useful supplement to raw Monetary for segments where high spend but very few orders may indicate a bulk B2B customer rather than a loyal consumer:
Wrap in IFERROR to handle customers with zero frequency: =IFERROR(D2/C2, 0).
Step 5 Score each dimension 1–5 using PERCENTILE thresholds
Rather than using arbitrary absolute thresholds (“anyone who spent over £500 gets score 5”), PERCENTILE-based scoring adapts automatically to your customer distribution. A customer who spent £300 might be in the top 20% for a small business but the bottom 20% for a large retailer. Percentile scoring always compares customers against each other.
Setting up the threshold table
On a helper sheet (or a side area of the RFM sheet), calculate the percentile breakpoints. For the Frequency and Monetary columns:
P40 (score boundary 2→3): =PERCENTILE(C:C, 0.40)
P60 (score boundary 3→4): =PERCENTILE(C:C, 0.60)
P80 (score boundary 4→5): =PERCENTILE(C:C, 0.80)
Name these cells F_P20, F_P40, F_P60, F_P80 (and equivalent M_ and R_ versions for Monetary and Recency) using the Name Box.
F_Score formula (higher Frequency = higher score)
R_Score formula (REVERSED — lower Recency days = higher score)
Note the reversed direction: customers with more days since last purchase (higher Recency value) get a lower score. R_P80 is the 80th percentile of the Recency days column — so “above P80 days” means the customer is in the most dormant 20% and gets score 1.
M_Score formula (higher Monetary = higher score)
Add three score columns: R_Score (col F), F_Score (col G), M_Score (col H). Then combine them into an RFM string in column I:
This creates values like “555” (Champion) or “133” (At Risk). And an overall RFM score in column J (optional, for quick sorting):
Step 6 Assign segment labels and build summary output
Add column K (Segment). Use IFS to map RFM string patterns to segment names. The full 125-combination mapping is impractical — use a simplified model that covers the highest-value marketing actions:
AND(F2=5,G2>=4,H2>=4), "Champion",
AND(F2>=4,G2>=3,H2>=3), "Loyal",
AND(F2>=4,G2<=2,H2>=3), "Potential Loyalist",
AND(F2<=2,G2>=4,H2>=4), "At Risk",
AND(F2<=1,H2>=4), "Can't Lose",
AND(F2<=2,G2<=2), "Hibernating",
AND(F2<=1,G2<=2,H2<=2), "Lost",
TRUE, "Needs Attention"
)
Standard RFM segments and what to do with them
Summary pivot table by segment
Insert a PivotTable from the RFM sheet. Drag Segment to Rows. Add CustomerID as Count to Values (how many customers per segment). Add Monetary as Sum to Values (total revenue per segment). Add Recency as Average to Values (average days dormant per segment). This gives you the segment distribution and tells you where your revenue is concentrated — typically Champions represent 10–15% of customers but 40–60% of revenue.
Exporting segment lists for marketing
To extract At Risk customers for a win-back campaign, use FILTER (Microsoft 365):
On Excel 2016/2019, use AutoFilter on the Segment column and copy visible rows. Export the CustomerID and email list to CSV and upload to your email platform (Klaviyo, Mailchimp, HubSpot) as a segment for targeted campaigns.
Automate RFM analysis in 60 seconds — no formulas needed
DataHub Pro runs the complete RFM model automatically from your transaction file. Upload your CSV or Excel — get Champion/At-Risk/Lost segments, revenue per segment, and exportable customer lists instantly.
See how it works →Frequently asked questions
What does RFM stand for?
RFM stands for Recency (how recently the customer made a purchase), Frequency (how often they purchase), and Monetary value (how much total revenue they generate). These three metrics together give a complete picture of customer value and engagement. A high-monetary, low-recency customer is at risk of churning. A high-recency, high-frequency customer is a Champion. No single metric captures this nuance on its own.
How many customers do I need for RFM analysis to be meaningful?
There is no hard minimum, but RFM segmentation works best with at least 200–300 customers who have made multiple transactions. With fewer customers, the percentile thresholds become unreliable and segments may contain very small counts. For very small customer bases (under 100), consider manually reviewing the top 20% and bottom 20% by monetary value rather than running a formal 5-tier scoring model.
Why is lower Recency better in RFM scoring?
Recency is measured as days since last purchase — a customer who bought yesterday has Recency = 1 and a customer who bought 365 days ago has Recency = 365. A lower number means more recent activity, which is better. When scoring, this means you reverse the normal direction: R_Score 5 goes to customers with the smallest Recency values (most recently active) and R_Score 1 goes to customers with the largest values (most dormant). Frequency and Monetary are scored normally: higher is better.
What is the difference between RFM and cohort analysis?
Cohort analysis groups customers by when they were acquired and tracks their behaviour over time — it answers “are customers acquired in January better retaining than those acquired in June?”. RFM analysis scores every customer based on their current cumulative behaviour — it answers “which customers are most valuable and most at risk today?”. The two complement each other: cohort tells you acquisition quality over time; RFM tells you the current health of the full customer base. See our cohort analysis tutorial for the step-by-step on building a retention grid.
How often should I re-run my RFM segmentation?
Monthly is the standard cadence for e-commerce and subscription businesses. Weekly is valuable for high-frequency transaction platforms. Quarterly is appropriate for B2B companies with long sales cycles. The key is consistency — running RFM on the same date each period makes segment migrations (customers moving from Champion to At-Risk) meaningful signals rather than noise from recency drift.
My MAXIFS formula returns 0 for some customers — why?
MAXIFS returning 0 usually means: (1) the CustomerID in your RFM sheet doesn’t exactly match the Transactions table — check for trailing spaces (use TRIM()), different capitalisation, or number-vs-text mismatch; (2) the date column in Transactions contains text strings rather than Excel date values — select a date cell and check the formula bar shows a number (like 46023), not a formatted date string. Use DATEVALUE() to convert text dates. Quick diagnostic: =COUNTIFS(Transactions[CustomerID], A2) returning 0 confirms a mismatch between the IDs.
Can I automate RFM analysis instead of building it manually in Excel?
Yes — DataHub Pro runs the full RFM segmentation automatically from your uploaded transaction file. It calculates Recency, Frequency, and Monetary values, applies percentile-based 1–5 scoring, assigns segment labels (Champions, Loyal, At Risk, Hibernating, Lost), and renders an interactive dashboard showing segment distribution, revenue per segment, and at-risk customer lists. The whole process takes under 60 seconds with no formula work.
Should I use quintiles (1–5) or quartiles (1–4) for RFM scoring?
Quintiles (1–5) are the most common standard, giving 125 possible RFM combinations (5×5×5). Quartiles (1–4) give 64 combinations and are easier to label when you have fewer customers. The choice doesn’t significantly affect analysis quality — what matters more is using percentile-based thresholds consistently rather than arbitrary absolute cutoffs like “anyone spending over £500 gets score 5”.
Further reading
- RFM segmentation — automatic from your Excel or CSV file
- Cohort analysis in Excel — build a retention grid
- KPI dashboard in Excel — step-by-step from raw data
- Anomaly detection in Excel — flag outliers with IQR and z-score
- Holt-Winters forecasting in Excel — seasonal triple exponential smoothing
- All Excel analytics tutorials →
