Project Hub

Project · Customer segments

Finding the 30% of customers who bring 77% of revenue, and who is slipping away

The problem

The business treats every customer the same, so it spends on people who would buy anyway and loses good customers without noticing.

The solution

An analysis that scores every customer on recency, frequency and spend, groups them into champions, loyal, new, at risk and lost, tracks how each starting month's customers return, and shows who to contact first in Power BI.

How it works

  • Clean: Invoices cleaned: returns, cancelled orders and missing customers handled
  • Score: Each customer scored on how recently, how often and how much they buy
  • Group: Customers grouped into champions, loyal, new, at risk and lost
  • Cohorts: How many customers from each starting month come back
  • Report: A Power BI page per group, with who to call first

A closer look

Mental model: every customer gets a recency, frequency and spend score from 1 to 4, and two questions sort them into 1,772 champions with 77% of revenue, 779 loyal, 364 new, 631 at risk with 12% of revenue, and 2,286 lost.
Two questions sort every customer into five groups.
Data flow: one box per step, in run order, from the input files to the report.
The steps, in run order.
 is the Power BI model: one fact table of 43,807 invoices joined to 5,832 scored customers, who carry scores and group, and a date table of 1,095 dates; the 14 measures sit in their own table.
The star schema: one fact table, two dimensions.
Chart: 1,067,371 invoice lines as received drop to 794,163 after four cleaning rules remove 34,335 exact duplicates, 235,151 lines with no customer ID, 3,662 non-product lines and 60 lines with no quantity or a zero price.
The lines each cleaning rule removes.
Chart: champions are 30% of customers and bring 77% of revenue; loyal are 13% with 3%, new 6% with 1%, at risk 11% with 12%, and lost 39% with 7%.
Share of customers against share of revenue.
Cohort chart: for each starting month from December 2009 to December 2011, the share of customers who bought again in each later month; about 21% buy again the next month, from 9% for December 2010 to 35% for December 2009.
How many of each month's new customers come back.

The code

still_buying = customers.r_score >= RULES["still_buying_min_recency_score"]
good = customers.f_score + customers.m_score >= RULES["good_customer_min_frequency_plus_spend"]
customers["segment"] = np.select(
    [still_buying & good, still_buying & (customers.orders == 1), still_buying, good],
    ["Champions", "New", "Loyal", "At risk"],
    default="Lost",
)
analysis/analysis.ipynb

The impact

  • The customers who bring most of the revenue, named: 1,772 champions bring 77% of it.
  • 631 good customers who stopped buying, listed biggest spender first.
  • Return rates by starting month: 20.8% of new customers buy again the next month.

The result

36,573 invoices: 30% of customers bring 77% of revenue, and 631 good customers are at risk.

Built with

  • Python
  • pandas
  • SQL
  • Power BI
  • DAX