Metrics: the first month counted is labelled as the existing customers

With a "Count from" month set, that month's cohort is everyone already
paying then, not only those new that month. Both cohort tables now say
"existing customers" under it, the help text explains, and both cohort
CSVs add an existing_customers column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 13:06:04 -07:00
co-authored by Claude Opus 5.5
parent a49d49713d
commit e320a64166
6 changed files with 21 additions and 6 deletions
+6 -1
View File
@@ -166,6 +166,7 @@ type Model struct {
First map[string]string // customer → the month they first paid (from Start): their cohort
Existing map[string]string // customer → the month first seen paying, for those already customers then (a renewal): no cohort
Start string // the first month counted ("" for all)
Base string // the month whose cohort is the customers already paying when counting starts; "" if none
Suggest *Suggestion // a start month worth considering, when none is set
}
@@ -244,6 +245,9 @@ func Build(d *db.DB, now time.Time) (*Model, error) {
month = s
}
startMonth := month.Format("2006-01")
if m.Start != "" {
m.Base = startMonth
}
var prev map[string]float64
ever := map[string]bool{}
for !month.After(now) {
@@ -360,6 +364,7 @@ func (m *Model) Recent(n int) []Month {
// starting MRR (net revenue retention by cohort).
type Cohort struct {
Month string
Existing bool // the base: customers already paying when counting starts, not new that month
Customers int
Start float64 // their MRR in their first month
Retained []float64 // percent of Start, for month 0, 1, 2…; -1 beyond today
@@ -384,7 +389,7 @@ func (m *Model) Cohorts(n, span int) []Cohort {
if len(cs) == 0 {
continue
}
co := Cohort{Month: mo.Month, Customers: len(cs)}
co := Cohort{Month: mo.Month, Existing: mo.Month == m.Base, Customers: len(cs)}
for _, c := range cs {
co.Start += mo.ByCustomer[c]
}