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

Distilled prompt

255 words

Follow our guide to build your own version: Get started (opens in a new tab)

Read the prompt before you paste it into an AI tool, and check that it only does what you expect.

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.

  • Custom visualization

    Sunburst chart

    A zoomable sunburst that breaks one metric down through up to three nested dimensions. Click a slice to zoom in, the center to zoom out, and an outer slice to drill through.

    By Metabase team

  • Custom visualization

    Strike zone

    Plots every pitch a pitcher threw where it crossed the plate, colored by pitch type, with the strike zone drawn from the batter's own zone limits. The example is Zack Wheeler's season.

    By Metabase team