You are viewing documentation for an older version.
Define Cohorts in Profiles
2 minute read
You can define cohorts along with any associated features and feature views in the profiles.yaml file.
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 |
|---|---|
nameRequired | Model name. |
model_typeRequired | Model type - set this parameter to entity_cohort. |
model_specRequired | 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
# 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/ordersView 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 and run it.

Contact the Profiles support team in RudderStack’s Community Slack if you are unable to see the Entities tab.