BizThinkFrame
Practice with data · 10 min read

Work through an RFM analysis with public retail data

Reproduce historical retail RFM results, compare filtering rules and customer lists, or paste aggregated customer results with definitions and investigation notes.

On this page

RFM summarizes recency, purchase frequency, and a defined monetary amount. Use the 2010–2011 UK retail records to calculate these measures: follow six deliberately selected customers by hand, then inspect results for all 4,338 eligible customers. The six are not representative. Reproduce the filtering and definitions to identify questions about customers; these measures alone do not establish marketing segments or actions.

If you already have customer-level R/F/M, the next question is what a threshold changes: who enters or leaves the list, and what should you investigate? The rule comparison works with all the historical results or a pasted table of your own aggregated results, without entering customers individually.

Understand the data before grouping customers

The UCI Online Retail dataset contains historical transactions from a UK non-store retailer between December 1, 2010 and December 9, 2011. The business sold gifts and included wholesale customers. Each row is an invoice item, not a customer or necessarily a separate purchase.

Invoice numbers, quantities, prices, timestamps, and customer IDs let us describe recorded purchases. They do not establish acquisition costs, profit, customer intentions, or the behavior of people who never purchased. This exercise does not estimate lifetime value or confirm that a customer has churned.

Data attribution: Chen, D. (2015), Online Retail, UCI Machine Learning Repository, DOI: 10.24432/C5BW33, licensed under CC BY 4.0. The downloadable results are derived teaching materials.

Make the filtering rules reproducible

Apply these exclusions in sequence. Each exclusion count refers to the rows still present at that step, so the counts can be added without double-counting.

Step Rows excluded Reason
Start — 541,909 source rows
Missing CustomerID 135,080 Cannot assign purchases to a known customer
Invoice number starting with C 8,905 Cancellation invoices
Quantity at or below zero 0 None remain after the preceding exclusions
Unit price at or below zero 40 Outside this positive-purchase definition
Eligible rows — 397,884 rows remain

The result contains 4,338 customers and 18,532 distinct invoice numbers. The original table has 5,268 exact duplicate rows. We preserve them because the data provides no unique line identifier that establishes accidental duplication. We do not additionally remove postage or manual-item codes.

Our monetary measure includes positive purchases and does not subtract cancellation records. It is not net revenue or profit. A different question may require different rules; record those rules before comparing results.

Define R, F, and M precisely

Use December 10, 2011 as the fixed reference date, immediately after the recorded period. Using today's date would change the meaning of this historical exercise.

  • Recency (R): calendar days between the customer's last eligible purchase date and the reference date. Lower means more recent. Use the calendar dates in the source.
  • Frequency (F): distinct eligible invoice numbers per customer. Several line items on one invoice count as one purchase.
  • Monetary value (M): the sum of quantity multiplied by unit price across eligible rows, in GBP. Calculate at full precision and round only for display.

For customer 12347, 182 eligible line items belong to 7 invoices. The last purchase was on December 7, so R is 3 days, F is 7, and M is GBP 4,310.00. Counting line items would incorrectly turn F into 182.

Read six customers before inventing segments

The six customer IDs below were deliberately selected for hand calculation. They are not a random or statistically representative sample.

Customer ID R: days F: invoices M: GBP
12347 3 7 4,310.00
12348 76 4 1,797.24
12349 19 1 1,757.55
12350 311 1 334.40
12352 37 8 2,506.04
12353 205 1 89.00

Six selected customers have different recency and frequency even when spending is similar; bars show days since the last purchaseOpen diagram at full size

Customers 12348 and 12349 have similar total spending but different purchase frequencies. Customer 12352 has more invoices than 12347 but a longer gap since the last purchase. Those differences suggest questions about purchase cycles and needs; they do not supply the answers.

A 311-day gap means no eligible purchase was recorded during that interval. It does not prove permanent churn. The customer may have a one-off need, buy seasonally, or purchase elsewhere. This dataset cannot distinguish those explanations on its own.

Treat thresholds as choices to test

Two illustrative queries on the full result are:

Condition Customers Possible next investigation
R at most 30 days and F at least 5 787 What needs or purchase cycles explain recent repeat buying?
R over 90 days and F at least 5 71 Is the gap unusual for these customers, given seasonality and normal purchase cycles?

These groups do not overlap, but they do not cover all customers. The thresholds are analyst choices for practice, not validated marketing segments or recommended campaign rules.

Set a rule as the baseline, then change recency or minimum frequency to inspect the customer IDs that enter and leave. Both rules use the same customers. A list change reflects a filtering choice, not a change in customer behavior. Customers outside a rule have not been established as unimportant.

Change a rule and inspect the investigation list

Start with all 4,338 historical customer results. R≤30 days and F≥5 selects 787; R>90 days and F≥5 selects 71. These thresholds are illustrative, not validated business boundaries.

Historical UK retail records, 2010-12-01 to 2011-12-09. Reference date: 2011-12-10; currency: GBP. R uses calendar days, F counts distinct eligible invoices, M is positive purchase amount; cancellations are not netted and exact duplicate rows are retained.

Loading the site's historical data. Without scripts, use the article downloads.

Current filtering rule

Baseline rule: R ≤ 30 days; F ≥ 5 purchases

Both rules use the same dataset and are recalculated together when personal data changes. Only R/F conditions change here; M remains visible for context.

The list is not a validated customer label. A long recorded gap does not establish churn, and purchase amount is not profit. Check purchase cycles, seasonality, and customer context.

Review the complete record
Historical teaching-data filtering record

Observation period, reference date, currency, and definitions:

Historical UK retail records, 2010-12-01 to 2011-12-09. Reference date: 2011-12-10; currency: GBP. R uses calendar days, F counts distinct eligible invoices, M is positive purchase amount; cancellations are not netted and exact duplicate rows are retained.

Baseline rule:

R ≤ 30 days; F ≥ 5 purchases

Current rule:

R ≤ 30 days; F ≥ 5 purchases

Raw filtering values:

{"op":"lte","days":"30","frequency":"5","beforeOp":"lte","beforeDays":"30","beforeFrequency":"5"}

No current calculation; previous results are not reused.


Investigation questions and remaining checks:

A list identifies customers to investigate, not churn, profit, or campaign effects.

Complete input:

Site material: rfm-all-customers.csv (4,338 customers); see the article downloads for source material and licensing.

Both rules use the same current customer data. List changes reflect filtering rules, not behavior changes across periods.

Use the list to ask further questions. Is the gap unusual for this customer's normal purchase cycle? What differs between one large order and several small orders? Does the group mix wholesale and individual customers? Check that context before considering interviews, follow-up, or further analysis. R/F conditions narrow an investigation; M remains visible for context. This exercise does not assign a universal customer-value score.

Ranking all customers by M, the top 20% rounded up—868 of 4,338 customers—account for about 74.62% of the positive purchase amount. Calculate the concentration instead of assuming an 80/20 split. This describes spending concentration under our rules, not profit concentration.

That concentration uses the same 4,338 customers, reference date, and monetary definition. The six hand-calculation examples do not estimate the full distribution, and the groups of 787 and 71 are selected investigation groups. If you subtract cancellations or remove duplicate rows, recalculate all results under the new policy. Differences between those monetary definitions are not evidence that customer behavior changed.

Enter your observation period, definitions and calculated summaries into the RFM guide outline to record customer observations and investigation questions. Its fictional CNY example uses different dates and refund rules from this historical GBP exercise. If your question concerns spending concentration, use the Pareto guide with totals measured on the same basis.

In personal mode above, paste four columns of aggregated customer results and record the observation period, reference date, currency, customer definition, cancellation policy, and duplicate policy. Take away the rules, full list, source text, and investigation notes together. This mode accepts calculated customer results; use the material's cleaning and aggregation process first if you are starting with invoice items.

Reproduce the result and record the limits

Start with the English source and reproduction notes. The original analysis date is October 3, 2026; the historical reference date remains December 10, 2011.

Before applying RFM elsewhere, write down the customer identifier, observation period, reference date, cancellation and duplicate policies, and exact R/F/M definitions. Then state what additional evidence you need before acting on a group. A clear calculation supports a better question; it does not turn a behavioral summary into a causal explanation.

Practice materials

Related frameworks

RFM analysis →Pareto analysis →

Continue exploring

New users aren’t coming back. What should you check first?Practice denominators and windows with separate fictional cohorts, keeping the datasets distinct.After SWOT: turn an idea into a testable actionWith customer observations, document action assumptions and test conditions.