All DAX Functions

Tracking Customer Retention with Cohort Analysis (M0, M1, M2…)

Build retention matrices with cohort month distance.

On this page

Overview

Cohort analysis groups customers by their first purchase month and tracks how many return in M0, M1, M2… (months since that first purchase). You build calculated columns on Orders, then a matrix visual for retention.

Calculated Columns

FirstPurchaseDate
FirstPurchaseDate =
CALCULATE(
    MIN ( Orders[OrderDate] ),
    ALLEXCEPT ( Orders, Orders[CustomerID] )
)
CohortMonth
CohortMonth =
EOMONTH ( Orders[FirstPurchaseDate], 0 )
MonthDistance
MonthDistance =
DATEDIFF (
    Orders[CohortMonth],
    EOMONTH ( Orders[OrderDate], 0 ),
    MONTH
)
CohortPeriod
CohortPeriod =
"M" & Orders[MonthDistance]
  • FirstPurchaseDate — anchor date per customer (ignores slicers except customer).
  • CohortMonth — end of month of first purchase; all customers acquired in Jan 2024 share one cohort.
  • MonthDistance — 0 in acquisition month, 1 next month, etc.
  • CohortPeriod — label M0, M1, M2 for matrix columns.

Matrix Visual Setup

  1. Insert a Matrix visual.
  2. Rows: CohortMonth (format as YYYY-MM or month name).
  3. Columns: CohortPeriod (sort by MonthDistance, not alphabetically).
  4. Values: Distinct Count of CustomerID (or a measure counting active customers in period).
  5. Optional: % of M0 measure = divide each cell by cohort size at M0 for retention rate.
  6. Slicer: Product Category or Region to compare cohorts side by side.

How to Read the Matrix

Example Retention Snapshot

CohortMonthM0M1M2M3
Jan 2024500210150120
Feb 2024420180130
Mar 2024600240

Each row is a acquisition cohort. M0 is customers in their first month (always the largest). M1 shows how many of that same cohort placed another order one month later—drop-off from 500 to 210 signals retention opportunity. Diagonal blanks are future months not yet observed. Compare M1/M0 across cohorts to see if recent acquisitions retain better than older ones.

Free Resource

Download Free Power BI Resource

Enter your details below to receive the instant download link directly in your inbox. We only use your email to send the requested file and occasional updates—no spam.

Link sent to your emailPrivacy respected