# Define Cohorts in Profiles

You can define [cohorts]({{< ref "profiles/concepts/cohort.md" >}}) along with any associated features and feature views in the [`profiles.yaml`]({{< ref "profiles/dev-docs/profiles-yaml/" >}}) file.

```yaml
models:
    - name: cohort_name
        model_type: entity_cohort
        model_spec:
            extends: cohort/path    # Optional
            materialization:        # Optional
                output_type: table\view  
            filter_expression:        # Optional
              AND/OR:
                - filter_condition
            feature_views:          # Optional
                - id: column
                  name: feature_view_name
  ```

| Key | Description |
| :------ | :-------- |
| `name` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span> | Model name. |
| `model_type` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span>     | Model type - set this parameter to `entity_cohort`. |
| `model_spec` <br/> <span style="color: #4D4DFF;font-size:12px;">Required</span>     | Model configuration. |
| `extends`         | Path to the parent cohort. `users/all` is used for all members of an entity. |
| `output_type` | Warehouse output, either `table` or `view`. |
| `filter_expression` | Defines the filters. |
| `type` | Filter type - accepted values are `include` or `exclude`. |
| `value` | SQL statement of rows to filter (similar to a `where` clause).    |
| `feature_view` | Defines the `id` and `name` of any views. |

## Example

```yaml
# Basic cohort

models:
    - name: knownUsers
      model_type: entity_cohort
      model_spec:
          extends: user/all
          materialization:
             output_type: table
          filter_expression: "{{ user.id_type_email_count }} > 0"

# A cohort of a cohort

models:
    - name: knownUsersOrderWithCC
      model_type: entity_cohort
      model_spec:
          extends: models/knownUsers
          materialization:
              output_type: view
         filter_expression:
            AND:
              - "{{ knownUsers.has_credit_card }} = 1"
              - "{{ knownUsers.order_total }} > 0"

# Adding a feature view to a cohort

models:
    - name: knownUsers
      model_type: entity_cohort
      model_spec:
          extends: user/all
          materialization:
              output_type: table
          filter_expression: "{{ user.id_type_email_count }} > 1"
          feature_views:
            name: known_users_feature_view
              - id: email
                name: known_users_by_email

# Combining two cohorts into a new cohort

models:
  - name: americanUsers
    model_type: entity_cohort
    model_spec:
       extends: user/all
       filter_expression:
        OR:
          - "{{ warehouse.EntityCohortCondition('models/north_american_users', 'in') }}"
          - "{{ warehouse.EntityCohortCondition('models/south_american_users', 'in') }}"

# Create var_group for a cohort

var_groups:
    - name: known_users_vars
      entity_cohort: models/knownUsers
      vars:
          - entity_var:
            name: last_transaction
            select: max(order_date)
            from: inputs/orders
```

## View cohorts in RudderStack dashboard

You can view the output for cohorts in the **Entities** tab of the UI once you [import a Profiles project from Git]({{< ref "profiles/management/import-from-git.md" >}}) and run it.

{{< image src="images/profiles/cohorts-view-ui.webp" alt="Entities Tab - Cohorts" >}}

{{< info >}}
Contact the Profiles support team in RudderStack's [Community Slack](https://rudderstack.com/join-rudderstack-slack-community) if you are unable to see the **Entities** tab.
{{< /info >}}

