Retail & Customer Insights
Who are our best customers, and who is drifting away?
- Scenario
- Customer and retail analytics
- Audience
- Owner, marketing and e-commerce leads
- Data
- About one million real online retail transactions from a UK-based retailer, 2009–2011
- Tools
- Power BI, Power Query, DAX
The challenge
An online retailer selling giftware, much of it to small trade buyers, has two years of transactions and no clear picture of its customers. Marketing sends the same emails to everyone. The owner wants to know who the best customers are, which customers are drifting away, and whether new customers acquired in one season behave differently from those acquired in another.
The business question is simple: who are our best customers, and who is drifting away?
The data
The project uses Online Retail II from the UCI Machine Learning Repository: about a million real transactions from a UK-based online retailer between December 2009 and December 2011. Each row is an invoice line with invoice number, stock code, description, quantity, invoice date, unit price, customer ID and country.
It is real-world data, with real-world faults:
- cancelled orders appear as separate invoices prefixed with “C”, with negative quantities;
- around a fifth of lines have no customer ID;
- some stock codes are postage, fees and manual adjustments rather than products;
- descriptions vary for the same stock code;
- a small number of lines have zero or negative prices.
The approach
Model. A star schema with a sales fact at invoice-line grain, and dimensions for date, customer, product and country. A customer-month table supports cohort and retention analysis without slowing the main report.
Transformation. Power Query separates cancellations and links them to the customer and period they affect. It moves non-product codes into their own category rather than deleting them, and picks one description per stock code. Lines without a customer ID stay in revenue totals but are excluded from customer analysis, and the report says so on every page where it matters.
Key measures. Recency, frequency and monetary value (RFM) scores for each customer, with segments such as “champions”, “loyal”, “at risk” and “lapsed”. Other measures include repeat purchase rate, average order value, cohort retention by month of first purchase, and the return and cancellation rate by product.
The dashboard
- Overview. Revenue, orders, active customers, repeat rate and average order value over time.
- Customer segments. RFM segments with their size, revenue share and movement between segments over the last quarter.
- Cohort retention. A heatmap of the share of each monthly cohort that buys again in following months.
- At-risk customers. Previously valuable customers whose buying has slowed, ranked by the revenue at stake.
- Products and countries. Best sellers, frequent returns and revenue outside the UK.
What it shows
The dashboard is designed to show how much of the revenue comes from a small group of repeat customers, how quickly new customers stop buying, and which previously valuable customers are going quiet.
[[UPDATE WITH REAL FINDINGS]]
Decisions it supports
- Which customers to contact first with a retention offer.
- Whether seasonal acquisition campaigns bring in customers who come back.
- Which products drive returns and cancellations.
- Segment-based marketing in place of one email for everyone.
Data source and licence
- Licence
- CC BY 4.0
- Attribution
- Chen, D. (2012). Online Retail II [Dataset]. UCI Machine Learning Repository. https://doi.org/10.24432/C5CG6D