Back to Supabase in Excel
SheetXAI logo
Supabase logo
Supabase · Excel Guide

Run a Cohort Retention SQL Query on Supabase and Pull Results Into an Excel Workbook

The Scenario

You are a growth analyst at a B2B SaaS startup. It is Tuesday at 4 PM and your head of growth wants a cohort retention table in an Excel workbook by end of day so she can build the board deck tonight.

The data is in your Supabase database: a users table and an events table. You need retention by cohort week — how many users who signed up in week 1 came back in week 2, week 3, and so on. Twenty-six cohorts, six weeks of data each.

The bad version of this afternoon:

  • You message the backend engineer to ask for database credentials
  • He sends a read-only connection string an hour later
  • You configure a Postgres ODBC driver in Excel — it takes 45 minutes
  • The driver connects but the query returns epoch timestamps, not readable dates
  • You spend 20 minutes cleaning the date columns
  • It is 6:30 PM. She needed it at 5:30.

The fast version is one prompt.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent inside your Excel workbook that runs the Supabase query for you, so you do not need to configure a database driver or touch the Supabase dashboard.

Open the SheetXAI sidebar and type:

Run this SQL against my Supabase project abc123: SELECT cohort_week, week_number, COUNT(DISTINCT user_id) AS retained_users FROM cohort_retention_view GROUP BY cohort_week, week_number ORDER BY cohort_week, week_number — write the results into this workbook starting at A1. Add a header row with readable column names: Cohort Week, Week Number, Retained Users.

SheetXAI calls Supabase, runs the query, and writes the result table into the workbook — header row included, column names readable.

What You Get

A formatted retention table ready for the board deck:

  • Header row — Cohort Week, Week Number, Retained Users
  • One row per cohort-week intersection — sorted chronologically
  • Clean date values — no epoch integers, no timezone offsets

You did not configure a driver or ask anyone for credentials. The analyst has what she needs. The board deck gets built tonight.

Want the data pivoted — cohorts as rows, week numbers as columns? Tell SheetXAI and it restructures the output inline.

What If the Data Is Not Quite Ready

Most production Supabase databases are not as tidy as a pre-built view. SheetXAI can handle joins, reshaping, and annotation in the same prompt.

When you need to write the join yourself

You do not have a cohort_retention_view — just raw users and events tables.

Run a SQL query on Supabase project abc123 that calculates cohort retention. Cohort week is the week_of_year of the user's created_at. Retention is based on whether the user has a login event in each subsequent week. Write results into this workbook as Cohort Week, Week Number, Retained Users.

When the result has timestamps instead of week labels

The query returns epoch integers for cohort dates.

Run the cohort SQL on Supabase project abc123 and write results into this workbook. Convert all cohort_week values from epoch milliseconds to a readable format like "2026-W01" before writing.

When you only want the last 8 cohorts

The full dataset spans two years and you only need recent cohorts for the board deck.

Run the cohort retention query on Supabase project abc123 — filter to cohorts that started in the last 8 weeks only. Write results into this workbook sorted oldest cohort first.

When you need the data cleaned, pivoted, and annotated in one shot

Run a cohort retention SQL on Supabase project abc123 joining users and events tables. Filter to the last 12 cohorts. Write raw results into the Raw tab. Pivot the data — cohort weeks as rows, week numbers as columns — and write the pivot into the Pivot tab. In cell A1 of the Summary tab, write one sentence describing the strongest and weakest cohort based on week-4 retention.

The pattern: instead of querying then cleaning then reshaping, you ask for all of it in one prompt.

Try It

Get the 7-day free trial of SheetXAI and open any Excel workbook, then ask it to run a SQL query against your Supabase project. The Supabase integration is included in every SheetXAI plan. For related workflows, see how to run a product analytics snapshot query or the Supabase in Excel overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more