# Cohorts (/docs/people/cohorts)

A cohort is a named group of players, such as *power players*, *new players*, *Premium players* or *repeat buyers*. Define it once and reuse it everywhere: as a filter, a breakdown, a flag target or an experiment segment.

| | Dynamic | Static |
| --- | --- | --- |
| Who's in | Everyone who matches your rules | A fixed list you add people to |
| Changes on its own | Yes. People join and leave as they behave. | No |
| Good for | "Bought something at least twice in 90 days" | Testers, moderators, a list of UserIds |

A third type, **SQL**, holds anyone a saved query returns (see below). Pick the type from the three cards at the top of the cohort page. You can switch an existing cohort's type too. RoChart tells you what you'd lose first: switching a dynamic cohort to **Static** keeps today's members as a fixed list and drops the rules, and switching to **Dynamic** replaces the list with rules. Nothing changes until you save.

## Build a dynamic cohort [#build-a-dynamic-cohort]

**People → Cohorts → New cohort.** Name it, keep the type on **Dynamic**, and choose whether people must match **all** or **any** of your rules (click the word to switch). Add rules with **+ Property**, **+ Behaviour** and **+ In another cohort**:

- **Property**: *country equals DE*, *platform is one of Phone, Tablet*, *premium equals true*.
- **Behaviour**: *performed* (or *did not perform*) an event *at least N times in the last N days*. Click **Total of a property** to add a sum, such as *total `$robux` ≥ 500*. You can also limit which events count, such as only `$product_type = game_pass`.
- **Cohort**: *in* or *not in* another cohort.

Each rule shows how many people are left after it, so you can see which rule does the narrowing. The **Right now** panel updates as you type, before you save: how many people match, their share of everyone, and a few of them (click one to open their profile). Save with **Create cohort** (or <kbd>⌘S</kbd>). For a saved cohort the panel also says when it was last calculated; click recalculate to refresh it.

Some examples:

| Cohort | Rules |
| --- | --- |
| Power players | Performed `$session_start` at least 10 times in the last 14 days |
| Tutorial finishers | Performed `tutorial_completed` in the last 7 days |
| Repeat buyers | Performed `$purchase` at least 2 times in the last 90 days |
| Big spenders | Performed `$purchase` with total `$robux` ≥ 2,000 in the last 90 days |
| Lapsed players | Performed `$session_start` in the last 90 days, **and** did not perform it in the last 14 days |
| Premium players | Person property `premium` equals `true` |

Time windows are counted back from today, so membership changes over time. A power player who stops playing drops out after 14 days.

Combine cohorts to keep rules short. For example, build *Paying power players* as *in Power players* **and** *in Repeat buyers*. A cohort can't include itself.

## Build a static cohort [#build-a-static-cohort]

Choose **Static** when you create it, and paste the initial members: one UserId or username per line. You can paste a spreadsheet column, because commas and tabs also work. People who can't be found are skipped.

Later, use **Add people** to paste more, remove people from the member list, or click **Add to cohort** on someone's profile.

## Build a cohort from SQL [#build-a-cohort-from-sql]

When a rule is easier to say in SQL, write it once in the [SQL Editor](/docs/product-analytics/sql) and save it. The query needs a `person_id` column:

```sql
SELECT person_id
FROM events
WHERE event = '$session_start'
GROUP BY person_id
HAVING min(timestamp) >= now() - INTERVAL 14 DAY -- first played in the last 14 days
```

Then either choose **SQL** when you create a cohort and pick the query, or open the query and use **⋯ → Use with people → Create cohort**. Members are the people the query returns. They're recalculated every hour, whenever the query changes, and when you click recalculate. A SQL cohort works everywhere other cohorts do.

## Use a cohort [#use-a-cohort]

| Where | How |
| --- | --- |
| Insights | **Analyse** on the cohort page opens a trend for its members. In any insight, filter by cohort or break down by cohorts to compare them. |
| Agents | Ask about one cohort, for example *"how long do repeat buyers play per day?"* Agents can filter any insight query by cohort. |
| Feature flags | Target a flag at the cohort, or at everyone *not* in it. See [Feature flags](/docs/feature-flags#who-gets-it). |
| Experiments | Report results per cohort. See [Segments](/docs/experiments/results#segments). |
| Feedback | Read only what one cohort is saying. |
| People | Filter the persons list to the cohort. |

Editing a cohort's rules applies everywhere from the next chart on. Flags pick up membership changes within about five minutes.

## Delete a cohort [#delete-a-cohort]

Use the **⋯** menu. A cohort that an experiment reports on can't be deleted, so remove it from the experiment first. Filters and flag rules that used a deleted cohort match nobody.
