About one new customer in five orders again the month after the first order: 21% on average across 22 monthly cohorts. Most come back eventually, though. Of the customers who had a full year to come back, 71% did, and returning customers brought in 80% of revenue in 2010 and 91% in 2011. Those are the cohort numbers a retailer's growth team watches, here computed from the invoices of a UK online shop that sells gifts and homewares, mostly to other businesses.
The data comes as a two-sheet Excel workbook, which is how a lot of business data arrives. This chapter reads it in place with DuckDB's excel extension. It then fixes the three things that would skew a cohort table: the sheets overlap, a fifth of the lines have no customer, and the first month mixes new customers with everyone who was already buying.
On average 21% of a cohort orders again the next month and 14% in month 11, then more return near Christmas
Months since first order 1 4 7 10 13 16 19 22 2009-12 (and earlier) Cohort (month of first order) 2009-12 (and earlier), months since first order 1: 35.0% Cohort (month of first order) 2009-12 (and earlier), months since first order 2: 33.3% Cohort (month of first order) 2009-12 (and earlier), months since first order 3: 42.5% Cohort (month of first order) 2009-12 (and earlier), months since first order 4: 37.9% Cohort (month of first order) 2009-12 (and earlier), months since first order 5: 36.0% Cohort (month of first order) 2009-12 (and earlier), months since first order 6: 37.6% Cohort (month of first order) 2009-12 (and earlier), months since first order 7: 34.4% Cohort (month of first order) 2009-12 (and earlier), months since first order 8: 33.8% Cohort (month of first order) 2009-12 (and earlier), months since first order 9: 36.2% Cohort (month of first order) 2009-12 (and earlier), months since first order 10: 42.2% Cohort (month of first order) 2009-12 (and earlier), months since first order 11: 49.6% Cohort (month of first order) 2009-12 (and earlier), months since first order 12: 37.6% Cohort (month of first order) 2009-12 (and earlier), months since first order 13: 28.2% Cohort (month of first order) 2009-12 (and earlier), months since first order 14: 24.4% Cohort (month of first order) 2009-12 (and earlier), months since first order 15: 30.3% Cohort (month of first order) 2009-12 (and earlier), months since first order 16: 26.3% Cohort (month of first order) 2009-12 (and earlier), months since first order 17: 30.3% Cohort (month of first order) 2009-12 (and earlier), months since first order 18: 28.4% Cohort (month of first order) 2009-12 (and earlier), months since first order 19: 25.9% Cohort (month of first order) 2009-12 (and earlier), months since first order 20: 25.4% Cohort (month of first order) 2009-12 (and earlier), months since first order 21: 31.3% Cohort (month of first order) 2009-12 (and earlier), months since first order 22: 30.4% Cohort (month of first order) 2009-12 (and earlier), months since first order 23: 40.6% Cohort (month of first order) 2009-12 (and earlier), months since first order 24: no data 2010-01 Cohort (month of first order) 2010-01, months since first order 1: 21.5% Cohort (month of first order) 2010-01, months since first order 2: 32.1% Cohort (month of first order) 2010-01, months since first order 3: 31.5% Cohort (month of first order) 2010-01, months since first order 4: 27.2% Cohort (month of first order) 2010-01, months since first order 5: 31.0% Cohort (month of first order) 2010-01, months since first order 6: 26.9% Cohort (month of first order) 2010-01, months since first order 7: 23.4% Cohort (month of first order) 2010-01, months since first order 8: 28.5% Cohort (month of first order) 2010-01, months since first order 9: 32.6% Cohort (month of first order) 2010-01, months since first order 10: 31.0% Cohort (month of first order) 2010-01, months since first order 11: 17.9% Cohort (month of first order) 2010-01, months since first order 12: 22.8% Cohort (month of first order) 2010-01, months since first order 13: 17.9% Cohort (month of first order) 2010-01, months since first order 14: 19.6% Cohort (month of first order) 2010-01, months since first order 15: 15.2% Cohort (month of first order) 2010-01, months since first order 16: 24.5% Cohort (month of first order) 2010-01, months since first order 17: 20.4% Cohort (month of first order) 2010-01, months since first order 18: 19.3% Cohort (month of first order) 2010-01, months since first order 19: 20.1% Cohort (month of first order) 2010-01, months since first order 20: 25.3% Cohort (month of first order) 2010-01, months since first order 21: 19.8% Cohort (month of first order) 2010-01, months since first order 22: 25.3% Cohort (month of first order) 2010-01, months since first order 23: no data Cohort (month of first order) 2010-01, months since first order 24: no data 2010-02 Cohort (month of first order) 2010-02, months since first order 1: 23.5% Cohort (month of first order) 2010-02, months since first order 2: 22.7% Cohort (month of first order) 2010-02, months since first order 3: 29.3% Cohort (month of first order) 2010-02, months since first order 4: 24.5% Cohort (month of first order) 2010-02, months since first order 5: 19.7% Cohort (month of first order) 2010-02, months since first order 6: 19.2% Cohort (month of first order) 2010-02, months since first order 7: 28.8% Cohort (month of first order) 2010-02, months since first order 8: 25.6% Cohort (month of first order) 2010-02, months since first order 9: 27.7% Cohort (month of first order) 2010-02, months since first order 10: 11.5% Cohort (month of first order) 2010-02, months since first order 11: 12.5% Cohort (month of first order) 2010-02, months since first order 12: 15.2% Cohort (month of first order) 2010-02, months since first order 13: 17.6% Cohort (month of first order) 2010-02, months since first order 14: 12.3% Cohort (month of first order) 2010-02, months since first order 15: 20.0% Cohort (month of first order) 2010-02, months since first order 16: 16.0% Cohort (month of first order) 2010-02, months since first order 17: 16.3% Cohort (month of first order) 2010-02, months since first order 18: 14.4% Cohort (month of first order) 2010-02, months since first order 19: 22.9% Cohort (month of first order) 2010-02, months since first order 20: 22.9% Cohort (month of first order) 2010-02, months since first order 21: 16.5% Cohort (month of first order) 2010-02, months since first order 22: no data Cohort (month of first order) 2010-02, months since first order 23: no data Cohort (month of first order) 2010-02, months since first order 24: no data 2010-03 Cohort (month of first order) 2010-03, months since first order 1: 19.0% Cohort (month of first order) 2010-03, months since first order 2: 23.1% Cohort (month of first order) 2010-03, months since first order 3: 24.3% Cohort (month of first order) 2010-03, months since first order 4: 23.1% Cohort (month of first order) 2010-03, months since first order 5: 20.4% Cohort (month of first order) 2010-03, months since first order 6: 24.7% Cohort (month of first order) 2010-03, months since first order 7: 30.6% Cohort (month of first order) 2010-03, months since first order 8: 27.7% Cohort (month of first order) 2010-03, months since first order 9: 10.9% Cohort (month of first order) 2010-03, months since first order 10: 11.6% Cohort (month of first order) 2010-03, months since first order 11: 14.5% Cohort (month of first order) 2010-03, months since first order 12: 20.0% Cohort (month of first order) 2010-03, months since first order 13: 16.3% Cohort (month of first order) 2010-03, months since first order 14: 20.0% Cohort (month of first order) 2010-03, months since first order 15: 17.0% Cohort (month of first order) 2010-03, months since first order 16: 17.5% Cohort (month of first order) 2010-03, months since first order 17: 15.6% Cohort (month of first order) 2010-03, months since first order 18: 17.7% Cohort (month of first order) 2010-03, months since first order 19: 20.4% Cohort (month of first order) 2010-03, months since first order 20: 21.3% Cohort (month of first order) 2010-03, months since first order 21: no data Cohort (month of first order) 2010-03, months since first order 22: no data Cohort (month of first order) 2010-03, months since first order 23: no data Cohort (month of first order) 2010-03, months since first order 24: no data 2010-04 Cohort (month of first order) 2010-04, months since first order 1: 19.0% Cohort (month of first order) 2010-04, months since first order 2: 19.0% Cohort (month of first order) 2010-04, months since first order 3: 16.0% Cohort (month of first order) 2010-04, months since first order 4: 18.4% Cohort (month of first order) 2010-04, months since first order 5: 22.1% Cohort (month of first order) 2010-04, months since first order 6: 27.6% Cohort (month of first order) 2010-04, months since first order 7: 26.5% Cohort (month of first order) 2010-04, months since first order 8: 10.5% Cohort (month of first order) 2010-04, months since first order 9: 10.9% Cohort (month of first order) 2010-04, months since first order 10: 7.5% Cohort (month of first order) 2010-04, months since first order 11: 13.9% Cohort (month of first order) 2010-04, months since first order 12: 14.3% Cohort (month of first order) 2010-04, months since first order 13: 15.6% Cohort (month of first order) 2010-04, months since first order 14: 15.6% Cohort (month of first order) 2010-04, months since first order 15: 15.6% Cohort (month of first order) 2010-04, months since first order 16: 13.9% Cohort (month of first order) 2010-04, months since first order 17: 15.0% Cohort (month of first order) 2010-04, months since first order 18: 18.0% Cohort (month of first order) 2010-04, months since first order 19: 22.8% Cohort (month of first order) 2010-04, months since first order 20: no data Cohort (month of first order) 2010-04, months since first order 21: no data Cohort (month of first order) 2010-04, months since first order 22: no data Cohort (month of first order) 2010-04, months since first order 23: no data Cohort (month of first order) 2010-04, months since first order 24: no data 2010-05 Cohort (month of first order) 2010-05, months since first order 1: 15.7% Cohort (month of first order) 2010-05, months since first order 2: 16.9% Cohort (month of first order) 2010-05, months since first order 3: 17.6% Cohort (month of first order) 2010-05, months since first order 4: 17.6% Cohort (month of first order) 2010-05, months since first order 5: 25.5% Cohort (month of first order) 2010-05, months since first order 6: 21.2% Cohort (month of first order) 2010-05, months since first order 7: 12.5% Cohort (month of first order) 2010-05, months since first order 8: 5.9% Cohort (month of first order) 2010-05, months since first order 9: 8.2% Cohort (month of first order) 2010-05, months since first order 10: 11.4% Cohort (month of first order) 2010-05, months since first order 11: 13.3% Cohort (month of first order) 2010-05, months since first order 12: 15.3% Cohort (month of first order) 2010-05, months since first order 13: 15.3% Cohort (month of first order) 2010-05, months since first order 14: 9.8% Cohort (month of first order) 2010-05, months since first order 15: 12.5% Cohort (month of first order) 2010-05, months since first order 16: 13.7% Cohort (month of first order) 2010-05, months since first order 17: 16.5% Cohort (month of first order) 2010-05, months since first order 18: 15.3% Cohort (month of first order) 2010-05, months since first order 19: no data Cohort (month of first order) 2010-05, months since first order 20: no data Cohort (month of first order) 2010-05, months since first order 21: no data Cohort (month of first order) 2010-05, months since first order 22: no data Cohort (month of first order) 2010-05, months since first order 23: no data Cohort (month of first order) 2010-05, months since first order 24: no data 2010-06 Cohort (month of first order) 2010-06, months since first order 1: 17.6% Cohort (month of first order) 2010-06, months since first order 2: 18.7% Cohort (month of first order) 2010-06, months since first order 3: 20.6% Cohort (month of first order) 2010-06, months since first order 4: 23.2% Cohort (month of first order) 2010-06, months since first order 5: 28.5% Cohort (month of first order) 2010-06, months since first order 6: 12.7% Cohort (month of first order) 2010-06, months since first order 7: 9.0% Cohort (month of first order) 2010-06, months since first order 8: 8.2% Cohort (month of first order) 2010-06, months since first order 9: 11.2% Cohort (month of first order) 2010-06, months since first order 10: 10.5% Cohort (month of first order) 2010-06, months since first order 11: 13.9% Cohort (month of first order) 2010-06, months since first order 12: 15.0% Cohort (month of first order) 2010-06, months since first order 13: 12.4% Cohort (month of first order) 2010-06, months since first order 14: 11.2% Cohort (month of first order) 2010-06, months since first order 15: 12.4% Cohort (month of first order) 2010-06, months since first order 16: 13.1% Cohort (month of first order) 2010-06, months since first order 17: 20.2% Cohort (month of first order) 2010-06, months since first order 18: no data Cohort (month of first order) 2010-06, months since first order 19: no data Cohort (month of first order) 2010-06, months since first order 20: no data Cohort (month of first order) 2010-06, months since first order 21: no data Cohort (month of first order) 2010-06, months since first order 22: no data Cohort (month of first order) 2010-06, months since first order 23: no data Cohort (month of first order) 2010-06, months since first order 24: no data 2010-07 Cohort (month of first order) 2010-07, months since first order 1: 15.7% Cohort (month of first order) 2010-07, months since first order 2: 18.4% Cohort (month of first order) 2010-07, months since first order 3: 29.7% Cohort (month of first order) 2010-07, months since first order 4: 29.2% Cohort (month of first order) 2010-07, months since first order 5: 14.1% Cohort (month of first order) 2010-07, months since first order 6: 11.4% Cohort (month of first order) 2010-07, months since first order 7: 14.6% Cohort (month of first order) 2010-07, months since first order 8: 14.6% Cohort (month of first order) 2010-07, months since first order 9: 11.4% Cohort (month of first order) 2010-07, months since first order 10: 13.5% Cohort (month of first order) 2010-07, months since first order 11: 14.6% Cohort (month of first order) 2010-07, months since first order 12: 13.0% Cohort (month of first order) 2010-07, months since first order 13: 13.5% Cohort (month of first order) 2010-07, months since first order 14: 19.5% Cohort (month of first order) 2010-07, months since first order 15: 17.3% Cohort (month of first order) 2010-07, months since first order 16: 23.8% Cohort (month of first order) 2010-07, months since first order 17: no data Cohort (month of first order) 2010-07, months since first order 18: no data Cohort (month of first order) 2010-07, months since first order 19: no data Cohort (month of first order) 2010-07, months since first order 20: no data Cohort (month of first order) 2010-07, months since first order 21: no data Cohort (month of first order) 2010-07, months since first order 22: no data Cohort (month of first order) 2010-07, months since first order 23: no data Cohort (month of first order) 2010-07, months since first order 24: no data 2010-08 Cohort (month of first order) 2010-08, months since first order 1: 19.6% Cohort (month of first order) 2010-08, months since first order 2: 28.8% Cohort (month of first order) 2010-08, months since first order 3: 32.5% Cohort (month of first order) 2010-08, months since first order 4: 16.6% Cohort (month of first order) 2010-08, months since first order 5: 11.7% Cohort (month of first order) 2010-08, months since first order 6: 9.8% Cohort (month of first order) 2010-08, months since first order 7: 12.9% Cohort (month of first order) 2010-08, months since first order 8: 13.5% Cohort (month of first order) 2010-08, months since first order 9: 12.9% Cohort (month of first order) 2010-08, months since first order 10: 12.9% Cohort (month of first order) 2010-08, months since first order 11: 11.7% Cohort (month of first order) 2010-08, months since first order 12: 14.7% Cohort (month of first order) 2010-08, months since first order 13: 17.2% Cohort (month of first order) 2010-08, months since first order 14: 17.2% Cohort (month of first order) 2010-08, months since first order 15: 19.6% Cohort (month of first order) 2010-08, months since first order 16: no data Cohort (month of first order) 2010-08, months since first order 17: no data Cohort (month of first order) 2010-08, months since first order 18: no data Cohort (month of first order) 2010-08, months since first order 19: no data Cohort (month of first order) 2010-08, months since first order 20: no data Cohort (month of first order) 2010-08, months since first order 21: no data Cohort (month of first order) 2010-08, months since first order 22: no data Cohort (month of first order) 2010-08, months since first order 23: no data Cohort (month of first order) 2010-08, months since first order 24: no data 2010-09 Cohort (month of first order) 2010-09, months since first order 1: 23.0% Cohort (month of first order) 2010-09, months since first order 2: 23.4% Cohort (month of first order) 2010-09, months since first order 3: 13.0% Cohort (month of first order) 2010-09, months since first order 4: 8.8% Cohort (month of first order) 2010-09, months since first order 5: 10.5% Cohort (month of first order) 2010-09, months since first order 6: 13.8% Cohort (month of first order) 2010-09, months since first order 7: 9.6% Cohort (month of first order) 2010-09, months since first order 8: 13.0% Cohort (month of first order) 2010-09, months since first order 9: 13.0% Cohort (month of first order) 2010-09, months since first order 10: 12.1% Cohort (month of first order) 2010-09, months since first order 11: 10.0% Cohort (month of first order) 2010-09, months since first order 12: 22.6% Cohort (month of first order) 2010-09, months since first order 13: 16.7% Cohort (month of first order) 2010-09, months since first order 14: 16.7% Cohort (month of first order) 2010-09, months since first order 15: no data Cohort (month of first order) 2010-09, months since first order 16: no data Cohort (month of first order) 2010-09, months since first order 17: no data Cohort (month of first order) 2010-09, months since first order 18: no data Cohort (month of first order) 2010-09, months since first order 19: no data Cohort (month of first order) 2010-09, months since first order 20: no data Cohort (month of first order) 2010-09, months since first order 21: no data Cohort (month of first order) 2010-09, months since first order 22: no data Cohort (month of first order) 2010-09, months since first order 23: no data Cohort (month of first order) 2010-09, months since first order 24: no data 2010-10 Cohort (month of first order) 2010-10, months since first order 1: 25.9% Cohort (month of first order) 2010-10, months since first order 2: 14.7% Cohort (month of first order) 2010-10, months since first order 3: 12.5% Cohort (month of first order) 2010-10, months since first order 4: 8.8% Cohort (month of first order) 2010-10, months since first order 5: 8.3% Cohort (month of first order) 2010-10, months since first order 6: 13.1% Cohort (month of first order) 2010-10, months since first order 7: 13.9% Cohort (month of first order) 2010-10, months since first order 8: 10.7% Cohort (month of first order) 2010-10, months since first order 9: 9.3% Cohort (month of first order) 2010-10, months since first order 10: 10.7% Cohort (month of first order) 2010-10, months since first order 11: 12.8% Cohort (month of first order) 2010-10, months since first order 12: 19.2% Cohort (month of first order) 2010-10, months since first order 13: 23.2% Cohort (month of first order) 2010-10, months since first order 14: no data Cohort (month of first order) 2010-10, months since first order 15: no data Cohort (month of first order) 2010-10, months since first order 16: no data Cohort (month of first order) 2010-10, months since first order 17: no data Cohort (month of first order) 2010-10, months since first order 18: no data Cohort (month of first order) 2010-10, months since first order 19: no data Cohort (month of first order) 2010-10, months since first order 20: no data Cohort (month of first order) 2010-10, months since first order 21: no data Cohort (month of first order) 2010-10, months since first order 22: no data Cohort (month of first order) 2010-10, months since first order 23: no data Cohort (month of first order) 2010-10, months since first order 24: no data 2010-11 Cohort (month of first order) 2010-11, months since first order 1: 17.5% Cohort (month of first order) 2010-11, months since first order 2: 9.5% Cohort (month of first order) 2010-11, months since first order 3: 9.5% Cohort (month of first order) 2010-11, months since first order 4: 7.7% Cohort (month of first order) 2010-11, months since first order 5: 8.9% Cohort (month of first order) 2010-11, months since first order 6: 12.9% Cohort (month of first order) 2010-11, months since first order 7: 10.1% Cohort (month of first order) 2010-11, months since first order 8: 8.6% Cohort (month of first order) 2010-11, months since first order 9: 9.2% Cohort (month of first order) 2010-11, months since first order 10: 11.0% Cohort (month of first order) 2010-11, months since first order 11: 14.7% Cohort (month of first order) 2010-11, months since first order 12: 25.2% Cohort (month of first order) 2010-11, months since first order 13: no data Cohort (month of first order) 2010-11, months since first order 14: no data Cohort (month of first order) 2010-11, months since first order 15: no data Cohort (month of first order) 2010-11, months since first order 16: no data Cohort (month of first order) 2010-11, months since first order 17: no data Cohort (month of first order) 2010-11, months since first order 18: no data Cohort (month of first order) 2010-11, months since first order 19: no data Cohort (month of first order) 2010-11, months since first order 20: no data Cohort (month of first order) 2010-11, months since first order 21: no data Cohort (month of first order) 2010-11, months since first order 22: no data Cohort (month of first order) 2010-11, months since first order 23: no data Cohort (month of first order) 2010-11, months since first order 24: no data 2010-12 Cohort (month of first order) 2010-12, months since first order 1: 9.2% Cohort (month of first order) 2010-12, months since first order 2: 5.3% Cohort (month of first order) 2010-12, months since first order 3: 9.2% Cohort (month of first order) 2010-12, months since first order 4: 11.8% Cohort (month of first order) 2010-12, months since first order 5: 6.6% Cohort (month of first order) 2010-12, months since first order 6: 5.3% Cohort (month of first order) 2010-12, months since first order 7: 9.2% Cohort (month of first order) 2010-12, months since first order 8: 5.3% Cohort (month of first order) 2010-12, months since first order 9: 2.6% Cohort (month of first order) 2010-12, months since first order 10: 9.2% Cohort (month of first order) 2010-12, months since first order 11: 19.7% Cohort (month of first order) 2010-12, months since first order 12: no data Cohort (month of first order) 2010-12, months since first order 13: no data Cohort (month of first order) 2010-12, months since first order 14: no data Cohort (month of first order) 2010-12, months since first order 15: no data Cohort (month of first order) 2010-12, months since first order 16: no data Cohort (month of first order) 2010-12, months since first order 17: no data Cohort (month of first order) 2010-12, months since first order 18: no data Cohort (month of first order) 2010-12, months since first order 19: no data Cohort (month of first order) 2010-12, months since first order 20: no data Cohort (month of first order) 2010-12, months since first order 21: no data Cohort (month of first order) 2010-12, months since first order 22: no data Cohort (month of first order) 2010-12, months since first order 23: no data Cohort (month of first order) 2010-12, months since first order 24: no data 2011-01 Cohort (month of first order) 2011-01, months since first order 1: 16.7% Cohort (month of first order) 2011-01, months since first order 2: 22.2% Cohort (month of first order) 2011-01, months since first order 3: 19.4% Cohort (month of first order) 2011-01, months since first order 4: 22.2% Cohort (month of first order) 2011-01, months since first order 5: 15.3% Cohort (month of first order) 2011-01, months since first order 6: 15.3% Cohort (month of first order) 2011-01, months since first order 7: 12.5% Cohort (month of first order) 2011-01, months since first order 8: 11.1% Cohort (month of first order) 2011-01, months since first order 9: 20.8% Cohort (month of first order) 2011-01, months since first order 10: 25.0% Cohort (month of first order) 2011-01, months since first order 11: no data Cohort (month of first order) 2011-01, months since first order 12: no data Cohort (month of first order) 2011-01, months since first order 13: no data Cohort (month of first order) 2011-01, months since first order 14: no data Cohort (month of first order) 2011-01, months since first order 15: no data Cohort (month of first order) 2011-01, months since first order 16: no data Cohort (month of first order) 2011-01, months since first order 17: no data Cohort (month of first order) 2011-01, months since first order 18: no data Cohort (month of first order) 2011-01, months since first order 19: no data Cohort (month of first order) 2011-01, months since first order 20: no data Cohort (month of first order) 2011-01, months since first order 21: no data Cohort (month of first order) 2011-01, months since first order 22: no data Cohort (month of first order) 2011-01, months since first order 23: no data Cohort (month of first order) 2011-01, months since first order 24: no data 2011-02 Cohort (month of first order) 2011-02, months since first order 1: 16.0% Cohort (month of first order) 2011-02, months since first order 2: 16.0% Cohort (month of first order) 2011-02, months since first order 3: 18.4% Cohort (month of first order) 2011-02, months since first order 4: 21.6% Cohort (month of first order) 2011-02, months since first order 5: 16.0% Cohort (month of first order) 2011-02, months since first order 6: 16.0% Cohort (month of first order) 2011-02, months since first order 7: 15.2% Cohort (month of first order) 2011-02, months since first order 8: 15.2% Cohort (month of first order) 2011-02, months since first order 9: 18.4% Cohort (month of first order) 2011-02, months since first order 10: no data Cohort (month of first order) 2011-02, months since first order 11: no data Cohort (month of first order) 2011-02, months since first order 12: no data Cohort (month of first order) 2011-02, months since first order 13: no data Cohort (month of first order) 2011-02, months since first order 14: no data Cohort (month of first order) 2011-02, months since first order 15: no data Cohort (month of first order) 2011-02, months since first order 16: no data Cohort (month of first order) 2011-02, months since first order 17: no data Cohort (month of first order) 2011-02, months since first order 18: no data Cohort (month of first order) 2011-02, months since first order 19: no data Cohort (month of first order) 2011-02, months since first order 20: no data Cohort (month of first order) 2011-02, months since first order 21: no data Cohort (month of first order) 2011-02, months since first order 22: no data Cohort (month of first order) 2011-02, months since first order 23: no data Cohort (month of first order) 2011-02, months since first order 24: no data 2011-03 Cohort (month of first order) 2011-03, months since first order 1: 17.9% Cohort (month of first order) 2011-03, months since first order 2: 21.8% Cohort (month of first order) 2011-03, months since first order 3: 20.1% Cohort (month of first order) 2011-03, months since first order 4: 22.3% Cohort (month of first order) 2011-03, months since first order 5: 15.1% Cohort (month of first order) 2011-03, months since first order 6: 20.7% Cohort (month of first order) 2011-03, months since first order 7: 20.1% Cohort (month of first order) 2011-03, months since first order 8: 24.0% Cohort (month of first order) 2011-03, months since first order 9: no data Cohort (month of first order) 2011-03, months since first order 10: no data Cohort (month of first order) 2011-03, months since first order 11: no data Cohort (month of first order) 2011-03, months since first order 12: no data Cohort (month of first order) 2011-03, months since first order 13: no data Cohort (month of first order) 2011-03, months since first order 14: no data Cohort (month of first order) 2011-03, months since first order 15: no data Cohort (month of first order) 2011-03, months since first order 16: no data Cohort (month of first order) 2011-03, months since first order 17: no data Cohort (month of first order) 2011-03, months since first order 18: no data Cohort (month of first order) 2011-03, months since first order 19: no data Cohort (month of first order) 2011-03, months since first order 20: no data Cohort (month of first order) 2011-03, months since first order 21: no data Cohort (month of first order) 2011-03, months since first order 22: no data Cohort (month of first order) 2011-03, months since first order 23: no data Cohort (month of first order) 2011-03, months since first order 24: no data 2011-04 Cohort (month of first order) 2011-04, months since first order 1: 24.5% Cohort (month of first order) 2011-04, months since first order 2: 19.8% Cohort (month of first order) 2011-04, months since first order 3: 19.8% Cohort (month of first order) 2011-04, months since first order 4: 17.9% Cohort (month of first order) 2011-04, months since first order 5: 23.6% Cohort (month of first order) 2011-04, months since first order 6: 17.9% Cohort (month of first order) 2011-04, months since first order 7: 25.5% Cohort (month of first order) 2011-04, months since first order 8: no data Cohort (month of first order) 2011-04, months since first order 9: no data Cohort (month of first order) 2011-04, months since first order 10: no data Cohort (month of first order) 2011-04, months since first order 11: no data Cohort (month of first order) 2011-04, months since first order 12: no data Cohort (month of first order) 2011-04, months since first order 13: no data Cohort (month of first order) 2011-04, months since first order 14: no data Cohort (month of first order) 2011-04, months since first order 15: no data Cohort (month of first order) 2011-04, months since first order 16: no data Cohort (month of first order) 2011-04, months since first order 17: no data Cohort (month of first order) 2011-04, months since first order 18: no data Cohort (month of first order) 2011-04, months since first order 19: no data Cohort (month of first order) 2011-04, months since first order 20: no data Cohort (month of first order) 2011-04, months since first order 21: no data Cohort (month of first order) 2011-04, months since first order 22: no data Cohort (month of first order) 2011-04, months since first order 23: no data Cohort (month of first order) 2011-04, months since first order 24: no data 2011-05 Cohort (month of first order) 2011-05, months since first order 1: 23.4% Cohort (month of first order) 2011-05, months since first order 2: 24.3% Cohort (month of first order) 2011-05, months since first order 3: 16.2% Cohort (month of first order) 2011-05, months since first order 4: 21.6% Cohort (month of first order) 2011-05, months since first order 5: 20.7% Cohort (month of first order) 2011-05, months since first order 6: 26.1% Cohort (month of first order) 2011-05, months since first order 7: no data Cohort (month of first order) 2011-05, months since first order 8: no data Cohort (month of first order) 2011-05, months since first order 9: no data Cohort (month of first order) 2011-05, months since first order 10: no data Cohort (month of first order) 2011-05, months since first order 11: no data Cohort (month of first order) 2011-05, months since first order 12: no data Cohort (month of first order) 2011-05, months since first order 13: no data Cohort (month of first order) 2011-05, months since first order 14: no data Cohort (month of first order) 2011-05, months since first order 15: no data Cohort (month of first order) 2011-05, months since first order 16: no data Cohort (month of first order) 2011-05, months since first order 17: no data Cohort (month of first order) 2011-05, months since first order 18: no data Cohort (month of first order) 2011-05, months since first order 19: no data Cohort (month of first order) 2011-05, months since first order 20: no data Cohort (month of first order) 2011-05, months since first order 21: no data Cohort (month of first order) 2011-05, months since first order 22: no data Cohort (month of first order) 2011-05, months since first order 23: no data Cohort (month of first order) 2011-05, months since first order 24: no data 2011-06 Cohort (month of first order) 2011-06, months since first order 1: 23.1% Cohort (month of first order) 2011-06, months since first order 2: 21.3% Cohort (month of first order) 2011-06, months since first order 3: 26.9% Cohort (month of first order) 2011-06, months since first order 4: 20.4% Cohort (month of first order) 2011-06, months since first order 5: 27.8% Cohort (month of first order) 2011-06, months since first order 6: no data Cohort (month of first order) 2011-06, months since first order 7: no data Cohort (month of first order) 2011-06, months since first order 8: no data Cohort (month of first order) 2011-06, months since first order 9: no data Cohort (month of first order) 2011-06, months since first order 10: no data Cohort (month of first order) 2011-06, months since first order 11: no data Cohort (month of first order) 2011-06, months since first order 12: no data Cohort (month of first order) 2011-06, months since first order 13: no data Cohort (month of first order) 2011-06, months since first order 14: no data Cohort (month of first order) 2011-06, months since first order 15: no data Cohort (month of first order) 2011-06, months since first order 16: no data Cohort (month of first order) 2011-06, months since first order 17: no data Cohort (month of first order) 2011-06, months since first order 18: no data Cohort (month of first order) 2011-06, months since first order 19: no data Cohort (month of first order) 2011-06, months since first order 20: no data Cohort (month of first order) 2011-06, months since first order 21: no data Cohort (month of first order) 2011-06, months since first order 22: no data Cohort (month of first order) 2011-06, months since first order 23: no data Cohort (month of first order) 2011-06, months since first order 24: no data 2011-07 Cohort (month of first order) 2011-07, months since first order 1: 20.8% Cohort (month of first order) 2011-07, months since first order 2: 29.7% Cohort (month of first order) 2011-07, months since first order 3: 27.7% Cohort (month of first order) 2011-07, months since first order 4: 34.7% Cohort (month of first order) 2011-07, months since first order 5: no data Cohort (month of first order) 2011-07, months since first order 6: no data Cohort (month of first order) 2011-07, months since first order 7: no data Cohort (month of first order) 2011-07, months since first order 8: no data Cohort (month of first order) 2011-07, months since first order 9: no data Cohort (month of first order) 2011-07, months since first order 10: no data Cohort (month of first order) 2011-07, months since first order 11: no data Cohort (month of first order) 2011-07, months since first order 12: no data Cohort (month of first order) 2011-07, months since first order 13: no data Cohort (month of first order) 2011-07, months since first order 14: no data Cohort (month of first order) 2011-07, months since first order 15: no data Cohort (month of first order) 2011-07, months since first order 16: no data Cohort (month of first order) 2011-07, months since first order 17: no data Cohort (month of first order) 2011-07, months since first order 18: no data Cohort (month of first order) 2011-07, months since first order 19: no data Cohort (month of first order) 2011-07, months since first order 20: no data Cohort (month of first order) 2011-07, months since first order 21: no data Cohort (month of first order) 2011-07, months since first order 22: no data Cohort (month of first order) 2011-07, months since first order 23: no data Cohort (month of first order) 2011-07, months since first order 24: no data 2011-08 Cohort (month of first order) 2011-08, months since first order 1: 26.2% Cohort (month of first order) 2011-08, months since first order 2: 29.9% Cohort (month of first order) 2011-08, months since first order 3: 26.2% Cohort (month of first order) 2011-08, months since first order 4: no data Cohort (month of first order) 2011-08, months since first order 5: no data Cohort (month of first order) 2011-08, months since first order 6: no data Cohort (month of first order) 2011-08, months since first order 7: no data Cohort (month of first order) 2011-08, months since first order 8: no data Cohort (month of first order) 2011-08, months since first order 9: no data Cohort (month of first order) 2011-08, months since first order 10: no data Cohort (month of first order) 2011-08, months since first order 11: no data Cohort (month of first order) 2011-08, months since first order 12: no data Cohort (month of first order) 2011-08, months since first order 13: no data Cohort (month of first order) 2011-08, months since first order 14: no data Cohort (month of first order) 2011-08, months since first order 15: no data Cohort (month of first order) 2011-08, months since first order 16: no data Cohort (month of first order) 2011-08, months since first order 17: no data Cohort (month of first order) 2011-08, months since first order 18: no data Cohort (month of first order) 2011-08, months since first order 19: no data Cohort (month of first order) 2011-08, months since first order 20: no data Cohort (month of first order) 2011-08, months since first order 21: no data Cohort (month of first order) 2011-08, months since first order 22: no data Cohort (month of first order) 2011-08, months since first order 23: no data Cohort (month of first order) 2011-08, months since first order 24: no data 2011-09 Cohort (month of first order) 2011-09, months since first order 1: 27.1% Cohort (month of first order) 2011-09, months since first order 2: 37.8% Cohort (month of first order) 2011-09, months since first order 3: no data Cohort (month of first order) 2011-09, months since first order 4: no data Cohort (month of first order) 2011-09, months since first order 5: no data Cohort (month of first order) 2011-09, months since first order 6: no data Cohort (month of first order) 2011-09, months since first order 7: no data Cohort (month of first order) 2011-09, months since first order 8: no data Cohort (month of first order) 2011-09, months since first order 9: no data Cohort (month of first order) 2011-09, months since first order 10: no data Cohort (month of first order) 2011-09, months since first order 11: no data Cohort (month of first order) 2011-09, months since first order 12: no data Cohort (month of first order) 2011-09, months since first order 13: no data Cohort (month of first order) 2011-09, months since first order 14: no data Cohort (month of first order) 2011-09, months since first order 15: no data Cohort (month of first order) 2011-09, months since first order 16: no data Cohort (month of first order) 2011-09, months since first order 17: no data Cohort (month of first order) 2011-09, months since first order 18: no data Cohort (month of first order) 2011-09, months since first order 19: no data Cohort (month of first order) 2011-09, months since first order 20: no data Cohort (month of first order) 2011-09, months since first order 21: no data Cohort (month of first order) 2011-09, months since first order 22: no data Cohort (month of first order) 2011-09, months since first order 23: no data Cohort (month of first order) 2011-09, months since first order 24: no data 2011-10 Cohort (month of first order) 2011-10, months since first order 1: 31.7% Cohort (month of first order) 2011-10, months since first order 2: no data Cohort (month of first order) 2011-10, months since first order 3: no data Cohort (month of first order) 2011-10, months since first order 4: no data Cohort (month of first order) 2011-10, months since first order 5: no data Cohort (month of first order) 2011-10, months since first order 6: no data Cohort (month of first order) 2011-10, months since first order 7: no data Cohort (month of first order) 2011-10, months since first order 8: no data Cohort (month of first order) 2011-10, months since first order 9: no data Cohort (month of first order) 2011-10, months since first order 10: no data Cohort (month of first order) 2011-10, months since first order 11: no data Cohort (month of first order) 2011-10, months since first order 12: no data Cohort (month of first order) 2011-10, months since first order 13: no data Cohort (month of first order) 2011-10, months since first order 14: no data Cohort (month of first order) 2011-10, months since first order 15: no data Cohort (month of first order) 2011-10, months since first order 16: no data Cohort (month of first order) 2011-10, months since first order 17: no data Cohort (month of first order) 2011-10, months since first order 18: no data Cohort (month of first order) 2011-10, months since first order 19: no data Cohort (month of first order) 2011-10, months since first order 20: no data Cohort (month of first order) 2011-10, months since first order 21: no data Cohort (month of first order) 2011-10, months since first order 22: no data Cohort (month of first order) 2011-10, months since first order 23: no data Cohort (month of first order) 2011-10, months since first order 24: no data 2011-11 Cohort (month of first order) 2011-11, months since first order 1: no data Cohort (month of first order) 2011-11, months since first order 2: no data Cohort (month of first order) 2011-11, months since first order 3: no data Cohort (month of first order) 2011-11, months since first order 4: no data Cohort (month of first order) 2011-11, months since first order 5: no data Cohort (month of first order) 2011-11, months since first order 6: no data Cohort (month of first order) 2011-11, months since first order 7: no data Cohort (month of first order) 2011-11, months since first order 8: no data Cohort (month of first order) 2011-11, months since first order 9: no data Cohort (month of first order) 2011-11, months since first order 10: no data Cohort (month of first order) 2011-11, months since first order 11: no data Cohort (month of first order) 2011-11, months since first order 12: no data Cohort (month of first order) 2011-11, months since first order 13: no data Cohort (month of first order) 2011-11, months since first order 14: no data Cohort (month of first order) 2011-11, months since first order 15: no data Cohort (month of first order) 2011-11, months since first order 16: no data Cohort (month of first order) 2011-11, months since first order 17: no data Cohort (month of first order) 2011-11, months since first order 18: no data Cohort (month of first order) 2011-11, months since first order 19: no data Cohort (month of first order) 2011-11, months since first order 20: no data Cohort (month of first order) 2011-11, months since first order 21: no data Cohort (month of first order) 2011-11, months since first order 22: no data Cohort (month of first order) 2011-11, months since first order 23: no data Cohort (month of first order) 2011-11, months since first order 24: no data 2011-12 Cohort (month of first order) 2011-12, months since first order 1: no data Cohort (month of first order) 2011-12, months since first order 2: no data Cohort (month of first order) 2011-12, months since first order 3: no data Cohort (month of first order) 2011-12, months since first order 4: no data Cohort (month of first order) 2011-12, months since first order 5: no data Cohort (month of first order) 2011-12, months since first order 6: no data Cohort (month of first order) 2011-12, months since first order 7: no data Cohort (month of first order) 2011-12, months since first order 8: no data Cohort (month of first order) 2011-12, months since first order 9: no data Cohort (month of first order) 2011-12, months since first order 10: no data Cohort (month of first order) 2011-12, months since first order 11: no data Cohort (month of first order) 2011-12, months since first order 12: no data Cohort (month of first order) 2011-12, months since first order 13: no data Cohort (month of first order) 2011-12, months since first order 14: no data Cohort (month of first order) 2011-12, months since first order 15: no data Cohort (month of first order) 2011-12, months since first order 16: no data Cohort (month of first order) 2011-12, months since first order 17: no data Cohort (month of first order) 2011-12, months since first order 18: no data Cohort (month of first order) 2011-12, months since first order 19: no data Cohort (month of first order) 2011-12, months since first order 20: no data Cohort (month of first order) 2011-12, months since first order 21: no data Cohort (month of first order) 2011-12, months since first order 22: no data Cohort (month of first order) 2011-12, months since first order 23: no data Cohort (month of first order) 2011-12, months since first order 24: no data 0.0% 50.0%
Retention triangle: percent of each monthly customer cohort ordering again in each of the following 23 months, December 2009 to November 2011 Cohort (month of first order) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2009-12 (and earlier) 35.0% 33.3% 42.5% 37.9% 36.0% 37.6% 34.4% 33.8% 36.2% 42.2% 49.6% 37.6% 28.2% 24.4% 30.3% 26.3% 30.3% 28.4% 25.9% 25.4% 31.3% 30.4% 40.6% — 2010-01 21.5% 32.1% 31.5% 27.2% 31.0% 26.9% 23.4% 28.5% 32.6% 31.0% 17.9% 22.8% 17.9% 19.6% 15.2% 24.5% 20.4% 19.3% 20.1% 25.3% 19.8% 25.3% — — 2010-02 23.5% 22.7% 29.3% 24.5% 19.7% 19.2% 28.8% 25.6% 27.7% 11.5% 12.5% 15.2% 17.6% 12.3% 20.0% 16.0% 16.3% 14.4% 22.9% 22.9% 16.5% — — — 2010-03 19.0% 23.1% 24.3% 23.1% 20.4% 24.7% 30.6% 27.7% 10.9% 11.6% 14.5% 20.0% 16.3% 20.0% 17.0% 17.5% 15.6% 17.7% 20.4% 21.3% — — — — 2010-04 19.0% 19.0% 16.0% 18.4% 22.1% 27.6% 26.5% 10.5% 10.9% 7.5% 13.9% 14.3% 15.6% 15.6% 15.6% 13.9% 15.0% 18.0% 22.8% — — — — — 2010-05 15.7% 16.9% 17.6% 17.6% 25.5% 21.2% 12.5% 5.9% 8.2% 11.4% 13.3% 15.3% 15.3% 9.8% 12.5% 13.7% 16.5% 15.3% — — — — — — 2010-06 17.6% 18.7% 20.6% 23.2% 28.5% 12.7% 9.0% 8.2% 11.2% 10.5% 13.9% 15.0% 12.4% 11.2% 12.4% 13.1% 20.2% — — — — — — — 2010-07 15.7% 18.4% 29.7% 29.2% 14.1% 11.4% 14.6% 14.6% 11.4% 13.5% 14.6% 13.0% 13.5% 19.5% 17.3% 23.8% — — — — — — — — 2010-08 19.6% 28.8% 32.5% 16.6% 11.7% 9.8% 12.9% 13.5% 12.9% 12.9% 11.7% 14.7% 17.2% 17.2% 19.6% — — — — — — — — — 2010-09 23.0% 23.4% 13.0% 8.8% 10.5% 13.8% 9.6% 13.0% 13.0% 12.1% 10.0% 22.6% 16.7% 16.7% — — — — — — — — — — 2010-10 25.9% 14.7% 12.5% 8.8% 8.3% 13.1% 13.9% 10.7% 9.3% 10.7% 12.8% 19.2% 23.2% — — — — — — — — — — — 2010-11 17.5% 9.5% 9.5% 7.7% 8.9% 12.9% 10.1% 8.6% 9.2% 11.0% 14.7% 25.2% — — — — — — — — — — — — 2010-12 9.2% 5.3% 9.2% 11.8% 6.6% 5.3% 9.2% 5.3% 2.6% 9.2% 19.7% — — — — — — — — — — — — — 2011-01 16.7% 22.2% 19.4% 22.2% 15.3% 15.3% 12.5% 11.1% 20.8% 25.0% — — — — — — — — — — — — — — 2011-02 16.0% 16.0% 18.4% 21.6% 16.0% 16.0% 15.2% 15.2% 18.4% — — — — — — — — — — — — — — — 2011-03 17.9% 21.8% 20.1% 22.3% 15.1% 20.7% 20.1% 24.0% — — — — — — — — — — — — — — — — 2011-04 24.5% 19.8% 19.8% 17.9% 23.6% 17.9% 25.5% — — — — — — — — — — — — — — — — — 2011-05 23.4% 24.3% 16.2% 21.6% 20.7% 26.1% — — — — — — — — — — — — — — — — — — 2011-06 23.1% 21.3% 26.9% 20.4% 27.8% — — — — — — — — — — — — — — — — — — — 2011-07 20.8% 29.7% 27.7% 34.7% — — — — — — — — — — — — — — — — — — — — 2011-08 26.2% 29.9% 26.2% — — — — — — — — — — — — — — — — — — — — — 2011-09 27.1% 37.8% — — — — — — — — — — — — — — — — — — — — — — 2011-10 31.7% — — — — — — — — — — — — — — — — — — — — — — — 2011-11 — — — — — — — — — — — — — — — — — — — — — — — — 2011-12 — — — — — — — — — — — — — — — — — — — — — — — —
Share of each cohort (customers grouped by the month of their first order) who ordered again in each later month, in percent. Grey cells are months the data does not reach. The top row is inflated: December 2009 is the first month in the data, so it includes every customer who was already buying (951 of them, against an average of 299 for the next eleven cohorts), and 35% of them ordered again in January, against 20% for the cohorts that follow. Source UCI Online Retail II, sale lines with a customer id, December 2009 to November 2011
Query chapters/13-shop-cohorts/pipeline/20_model.sqlShow SQL 20_model.sql SQL Copy SELECT c.cohort, date_diff( 'month' , c.cohort, o.month) AS month_offset,
count ( DISTINCT o.customer) AS active
FROM orders o JOIN customers c USING (customer)
GROUP BY ALL;
The data
Size 1,067,371 rows in two sheets of one .xlsx workbook
Grain One invoice line: a stock code, quantity and unit price on one invoice
Missing Customer names, types (wholesale or retail) and acquisition channel; costs and margins; any line without a customer id cannot be linked to a customer
License CC BY 4.0
Access Zip from the UCI repository, read with the excel extension
Snapshot Downloaded 3 December 2026; invoices from 1 December 2009 to 9 December 2011
The shop is a UK-based online retailer of gifts and homewares whose customers are, in the dataset's description, mostly wholesalers. Each line has an invoice number (a leading C marks a cancellation), a stock code, a description, a quantity, the invoice date and time, a unit price in pounds sterling, a customer id and the customer's country. UCI first published the second year alone as "Online Retail" (id 352), which most tutorials use; this release adds the first year.
Pipeline at a glance
1 Read both sheets as text 10_stage.sql 2 Remove the overlap between the sheets 10_stage.sql 3 Label every line before counting anything 10_stage.sql 4 Score customers with NTILE 20_model.sql Read both sheets as text
read_xlsx takes one sheet per call. The Invoice column holds numbers (489434) and text (C489449), so type detection fails on the first cancellation; reading every cell as text and casting afterward avoids that. Dates then arrive as Excel serial numbers, days since 30 December 1899.
10_stage.sql SQL Copy CREATE OR REPLACE MACRO excel_ts( serial ) AS
TIMESTAMP '1899-12-30' + to_milliseconds( round ( serial ::DOUBLE * 86400000 ):: BIGINT );
SELECT 'Year 2009-2010' AS sheet, * FROM sheet( 'Year 2009-2010' )
UNION ALL
SELECT 'Year 2010-2011' AS sheet, * FROM sheet( 'Year 2010-2011' ); 525,461 + 541,910 rows chapters/13-shop-cohorts/pipeline/10_stage.sql
Remove the overlap between the sheets
The second sheet starts on 1 December 2010 and the first ends on 9 December, so nine days are in both. EXCEPT ALL removes from the second sheet only the lines the first already has, counting duplicates, so two identical lines on one invoice stay two lines.
10_stage.sql SQL Copy SELECT * EXCLUDE (sheet) FROM raw_lines WHERE sheet = 'Year 2009-2010'
UNION ALL
( SELECT * EXCLUDE (sheet) FROM raw_lines WHERE sheet = 'Year 2010-2011'
EXCEPT ALL
SELECT * EXCLUDE (sheet) FROM raw_lines WHERE sheet = 'Year 2009-2010' ); 22,523 rows removed, 1,044,848 kept chapters/13-shop-cohorts/pipeline/10_stage.sql
Label every line before counting anything
A cohort table should count sales only. Cancellations, postage and fees, stock write-offs (zero price) and lines without a customer id are labelled and kept out of it.
10_stage.sql SQL Copy CASE WHEN invoice LIKE 'C%' THEN 'cancellation'
WHEN invoice LIKE 'A%' THEN 'bad-debt adjustment'
WHEN NOT is_product(sku) THEN 'postage, fee or manual entry'
WHEN qty <= 0 OR price <= 0 THEN 'stock adjustment'
WHEN customer IS NULL THEN 'sale, no customer id'
ELSE 'sale' END AS kind 6 kinds chapters/13-shop-cohorts/pipeline/10_stage.sql
Score customers with NTILE
RFM scoring ranks customers into fifths by recency, frequency and money spent, using ntile(5) over each measure.
20_model.sql SQL Copy SELECT customer, ntile ( 5 ) OVER ( ORDER BY last_ts) AS r,
ntile ( 5 ) OVER ( ORDER BY orders, revenue) AS f,
ntile ( 5 ) OVER ( ORDER BY revenue) AS m
FROM customers; 5 segments chapters/13-shop-cohorts/pipeline/20_model.sql
A known value checks.sql confirms UCI's count of 1,067,371 rows and that the older release is the second sheet minus one line, the last postage charge on invoice 581587.
Of all lines, 75% are sales with a customer, worth £17.1 million. Another 22% are sales with no customer id, worth £2.6 million; they cannot be put in a cohort, so every rate below is for identified customers. Cancellations total £1.5 million.
Repeat rates fall to 13% by month 10 and rise in month 12, when last year's Christmas buyers return
5 10 15 20 Months since first order 0.0% 10.0% 20.0% 30.0% 40.0% Cohort ordering that month (%) Share of a cohort ordering in each month after the first, pooled over cohorts from January 2010 onward that are observed for that month; the band spans the lowest and highest cohort. Month 12 averages 18% against 14% in month 11. Later months rest on fewer cohorts (1 in month 22). Source UCI Online Retail II, January 2010 to November 2011
Monthly repeat rates understate how many customers return eventually, because a customer who orders every quarter is active in only one month of three. Counting any return, 20% of new customers ordered again within 30 days, 43% within 90 and 71% within a year, among the 3,334 who were first seen at least a year before the data ends. For those who came back within the year, the median wait was 64 days.
In 2011 the shop held revenue flat on half as many new customers
2010 2011 2011 2012 £0k £200k £400k £600k £800k £1,000k £1,200k Sales per month (£ thousands) Monthly sales to identified customers, in thousands of pounds, split by whether the customer had ordered in an earlier month. From January to November, new customers numbered 3,288 in 2010 and 1,509 in 2011; sales were £7.68 million and £7.68 million. December 2009 counts every customer as new, and December 2011 (nine days) is left off. Source UCI Online Retail II, sale lines with a customer id
Every November is the peak month, as retailers stock up for Christmas. The second autumn's peak came almost entirely from customers who already knew the shop: returning customers were 91% of January-to-November sales in 2011, against 80% in 2010. The data cannot say whether fewer businesses found the shop or the shop spent less on finding them.
The top 10% of customers account for 64% of revenue
0 20 40 60 80 100 Customers, largest first (%) 0% 20% 40% 60% 80% 100% Revenue (%) Cumulative share of revenue against cumulative share of customers, ranked from largest to smallest, in percent. The top 1% of customers bought 32% of everything and the top 20% bought 77%. The 72% of customers with more than one order account for 97% of revenue. Source UCI Online Retail II, December 2009 to December 2011
RFM segments turn the same table into a list of actions. On 10 December 2011, the day after the last invoice, customers who are both recent and frequent (top two fifths on each) are 25% of customers and 69% of revenue. The segment worth a call is the 349 customers who ordered often (a median of 6 orders) but not for a median of 334 days; they bought 6% of everything.
The 25% of customers who are recent and frequent bought 69% of everything
RFM segments on 10 December 2011. Recency, frequency and spending are each split into fifths with ntile(5); best means top two fifths on recency and frequency, at risk means top two on frequency and bottom two on recency, and so on. Click a header to sort. Source UCI Online Retail II, December 2009 to December 2011
The dashboard below runs the chapter's data in your browser. The pipeline writes three Parquet extracts (every order with its customer's cohort and country, the customer list, and sales by year, country and product) to public storage, 1.2 MB in all, and DuckDB-Wasm reads them over HTTP range requests. Pick a country and the retention triangle, revenue split and rankings are recomputed from the orders. Every panel shows its SQL. The Ask box at the bottom hands your question to an AI model that writes the SQL; the query runs here, on the same files, and the model only sees the small result. Its answers are live and unaudited, unlike the numbers above.
The chapter's data sits in 3 Parquet files on public storage, 1.1 MB in all. Start the engine and DuckDB runs inside this page: each chart below is a SQL query that reads only the row groups and columns it needs over HTTP range requests.
ordersEvery order: customer, time, cohort, country, amount customersEvery customer: first month, country, orders, revenue productsSales by year, customer country and product Start live dataQueries this chapter's published snapshot; the data does not update in real time. No account, nothing uploaded.
Caveats
The first cohort is not new customers. Any cohort table built on data with a start date puts everyone already buying into the first month. The page shows that row but leaves it out of every average.
Unidentified sales. 22% of lines have no customer id. If those are one-off buyers, true repeat rates are lower than shown.
Gross of cancellations. Revenue counts sales lines; cancellations are reported separately and not netted against the customer who cancelled.
Businesses, not households. Most customers are resellers, whose ordering follows their own stock cycles. Rates from a consumer shop would be lower.
One shop, 2009 to 2011. The pattern, not the level, is what transfers.
Shell Copy DOWNLOAD = 1 bash chapters/13-shop-cohorts/pipeline/run.sh # two UCI zips, then stage, model, export, checks
A cohort analysis is a few GROUP BYs once the lines are clean, and most of the work is deciding what counts. Read the workbook as text and cast it yourself, remove any overlap between files with EXCEPT ALL so real duplicates survive, label every line instead of filtering silently, and mark the first cohort as censored. Full pipeline: chapters/13-shop-cohorts .