Custom visualization
Cohort retention heatmap
A retention triangle: rows are the month an account first paid, columns are months since then, and each cell is the share of that cohort still active. Hover for counts, click to drill through.
Shared by Metabase team
Screenshots
Distilled prompt
Follow our guide to build your own version: Get started (opens in a new tab)
Build a Metabase custom visualization (custom viz SDK v2) called "cohort-retention" that renders a cohort retention table as a heatmap triangle.
Input: three columns from a SQL or structured question:
- Cohort: the month an account first paid (a date).
- Period: whole months since that first payment (0, 1, 2…).
- Value: distinct accounts active in that period.
The example question takes the latest 18 cohorts of accounts with invoices.
Settings: let the user choose the cohort, period and value columns, defaulting to the first date column, the first integer column and the last numeric column.
Layout:
- One row per cohort, oldest at the top, labeled with the cohort date and a Size column (the period-0 count).
- One column per period, under a "Months Since First Payment" header.
- Each cell shows the value as a percent of that cohort's size. Period 0 is always 100%.
- Add an "Average" row at the top: the mean retention per period across the cohorts that have reached it.
- Leave cells blank where a cohort hasn't reached that period yet, so the table forms a triangle.
Color: a single-hue sequential blue scale from the Metabase palette. Darker means higher retention. Keep text readable on dark cells.
Interactions: hovering a cell shows a tooltip with the cohort, period, active count, cohort size and percent. Clicking a cell drills through to the underlying rows for that cohort and period.
Keep the header and the cohort labels sticky while scrolling, and follow Metabase's light and dark themes.