For the complete documentation index, see llms.txt. This page is also available as Markdown.

Aggregated Fields

Calculate a value from multiple records in a related model.

Aggregated fields calculate a single value from multiple records in a related model.

Use them when a record in your parent model is linked to several records in another model. For example, a customer can be linked to many transactions, so you can calculate total revenue, number of purchases, or average basket value.

Create an aggregated field

  1. Choose the parent model where the field will be created.

  2. Select the related model that contains the records to aggregate.

  3. Select an aggregation method.

  4. Choose the field to aggregate when the method requires one.

  5. Optionally add filters to include only relevant records.

Aggregated field configuration
Select the related model, aggregation method, field, and optional filters.

Available aggregation methods

Method
Description
Example

Count

Counts related records.

Number of purchases per customer.

Distinct count

Counts unique values.

Number of distinct product categories purchased.

Sum

Adds numeric values.

Total revenue per customer.

Average

Calculates the mean of numeric values.

Average basket value.

Minimum

Returns the lowest value.

Lowest transaction amount.

Maximum

Returns the highest value.

Highest transaction amount.

Most frequent

Returns the most common value.

Most purchased product category.

List aggregation

Returns a list of values.

List of product IDs purchased by a customer.

Filter the records to aggregate

Use filters to limit the records included in the calculation.

For example, you can calculate:

  • Revenue from completed transactions only.

  • Number of purchases in the last 30 days.

  • Average basket value for a specific product category.

Filters are applied before the aggregation is calculated.

Example: customer lifetime value

To create a lifetime_value field on a Customers model:

  1. Select Customers as the parent model.

  2. Select Transactions as the related model.

  3. Choose Sum.

  4. Select the transaction amount field.

  5. Filter transactions to include completed purchases only.

The resulting field can then be used in segments and activation mappings.

Last updated