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

Bulk Create PostHog Cohorts From an Excel workbook Filter Table

2026-05-15
5 min read

The Scenario

A lifecycle marketing analyst is starting her second week and has just discovered that the PostHog cohorts backing the in-app messaging campaigns don't exist yet. Her predecessor's handoff workbook has 10 rows — each with a cohort name and a behavioral filter description. The campaign launches in two days. The original plan was to create each cohort manually through the PostHog UI. There are 10 cohorts. Each one has a multi-condition filter. Doing this by hand means 10 separate UI sessions, and one filter typo will silently break the segment targeting without any warning.

The bad version:

  • Open PostHog's cohort creation UI, enter cohort name from row 1, click "Add filter," pick filter type, set property name, condition, value — repeat for each filter condition, save, move to cohort 2
  • Reach cohort 6 and realize the filter descriptions in the workbook are in plain English and don't map cleanly to PostHog's filter schema — spend 20 minutes translating the description before you can enter it
  • Finish all 10, set up the first campaign, discover cohort 7 returns zero members because a filter property name has a trailing space that the UI accepted but PostHog rejects during evaluation

Ten cohorts, each with multi-condition filters, two days until launch. Manual UI entry is the wrong tool.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent inside your Excel workbook. It reads your cohort definition table, translates filter descriptions into PostHog's expected format, creates each cohort, and writes the returned IDs back for immediate campaign use.

Create a PostHog project cohort for each row in the 'Cohort Definitions' worksheet — cohort name in column A, filter JSON in column B — and write the returned cohort ID into column C.

What You Get

  • PostHog creates one cohort per row using name and filter from the workbook
  • Column C receives the PostHog cohort ID for each row — ready to reference in campaign setup
  • Rows that fail are noted with the specific API error so you can fix and re-run only those

What If the Data Is Not Quite Ready

Filter definitions are in plain English

For each row in the 'Cohort Definitions' worksheet, interpret the behavioral description in column B as a PostHog cohort filter, create the cohort with name from column A, and write the returned cohort ID into column C. Write the interpreted filter JSON into column D so I can review it.

You want to export cohort membership after creation

For cohort ID 4521, retrieve the list of persons in that cohort and write each person's distinct_id and email (if available) into columns A and B of the 'Cohort Export' worksheet. Write the total count at the bottom of column A.

Some cohorts may already exist

Before creating cohorts from the workbook, check if a cohort with the same name already exists in PostHog. Write the existing ID into column C and skip creation for those rows. For new cohorts, create them and write the new ID into column C.

Create all cohorts, verify member counts, and flag empties

Create a PostHog cohort for each row in the 'Cohort Definitions' worksheet using name from column A and filter JSON from column B. Write cohort IDs into column C. For each created cohort, fetch the member count and write it into column D. In column E, write "Empty cohort - check filter" for any cohort with a member count of zero.

Build the cohorts and immediately validate they're working — one prompt.

Try It

Get the 7-day free trial of SheetXAI and open the Excel workbook where your segmentation definitions are drafted, ask it to create the PostHog cohorts, and have all 10 live before the campaign launch. Related: Bulk Add Users to a PostHog Static Cohort From an Excel workbook and the PostHog hub.

Stop memorizing formulas.
Tell your spreadsheet what to do.

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

Learn more