Computed Attributes
Computed attributes are derived metrics about customer entities. They transform raw warehouse data into meaningful values — like a customer’s lifetime value, their most-purchased product category, or the number of days since their last login — that can then be used to build audiences.
What Is a Computed Attribute?
A computed attribute is a single computed value attached to an entity type. Every computed attribute produces one value per entity instance. For example, a computed attribute called total_order_value on the User entity type would compute one number for each user in your warehouse.
Computed attributes are warehouse-native and computed on read: Zeotap generates SQL and runs it directly against your data warehouse whenever the attribute is referenced — in an audience, an estimate, a sync, or a journey. No data is copied out of your warehouse to compute them, and no values are stored in a separate table. Each result always reflects your latest warehouse data and the latest definition.
Computed Attribute Types
Zeotap offers six ways to define computed attributes, ranging from full SQL flexibility to visual no-code builders:
| Type | What it produces |
|---|---|
| Aggregation | A count, sum, average, min or max over related records |
| Occurrence | A single value picked by position or frequency — first, last, most or least frequent |
| List | Related values collected into a list |
| List of objects | The top N related rows as a list of objects |
| SQL | Anything you can express as a SQL expression |
| Formula | A new value composed from computed attributes you already have |
SQL Computed Attributes
SQL Computed Attributes let you write custom SQL to compute any metric. This is the most flexible option — anything you can express in a SQL query, you can turn into a computed attribute.
Use when: You need multi-table joins, window functions, CTEs, warehouse-specific functions, or any computation that doesn’t fit the visual builders.
-- Example: Customer lifetime value
SELECT
user_id,
SUM(order_total) - SUM(refund_amount) AS lifetime_value
FROM orders
LEFT JOIN refunds ON orders.order_id = refunds.order_id
GROUP BY user_idAggregation Computed Attributes
Aggregation Computed Attributes use a visual builder to define common aggregations without writing SQL. You pick a source table, an aggregation function, a column to aggregate, and optional filters.
Use when: You need a straightforward count, sum, average, min, max, or count distinct over a single table.
Supported functions:
| Function | Description | Example |
|---|---|---|
| Count | Number of rows | Total number of orders |
| Sum | Sum of a numeric column | Total revenue |
| Average | Mean of a numeric column | Average order value |
| Min | Minimum value | First purchase date |
| Max | Maximum value | Most recent login |
| Count Distinct | Unique values in a column | Number of distinct products purchased |
Occurrence Computed Attributes
Occurrence attributes pick one value out of a customer’s related rows, chosen by position in time or by how often it appears.
Use when: you want “the value that came first”, “the latest one”, or “the one they pick most often” — a first-touch channel, a most-recent shipping city, a favourite product category.
| Function | Picks |
|---|---|
| First | The value on the earliest related row |
| Last | The value on the most recent related row |
| Most frequent | The value that appears on the most related rows |
| Least frequent | The value that appears on the fewest |
First and Last need to know what “earliest” means, so they order by an order column. Leave it unset and the source model’s timestamp column is used; a model with no timestamp column requires you to name one explicitly.
List Computed Attributes
List attributes collect a column’s values across a customer’s related rows into a single list.
Use when: you want every value rather than one — all the categories someone has bought from, every campaign that touched them.
Options are a value column, an optional distinct toggle to collapse repeats, an optional limit on how many values to keep, and filters to narrow which related rows count.
List of Objects Computed Attributes
List-of-objects attributes collect whole related rows — several columns each — rather than one column’s values.
Use when: a list of bare values loses too much. “The last 10 products purchased” is only useful with the product name, price and date together.
You choose which columns to capture, the key each becomes in the resulting object, how the rows are ordered, and how many to keep. The result is an array of objects, which destinations that accept nested payloads can receive directly.
Formula Computed Attributes
Formula Computed Attributes combine existing computed attributes using arithmetic and logical expressions. They operate on the results of other computed attributes, resolved as part of the same on-read computation.
Use when: You want to derive new metrics from computed attributes you’ve already built, like ratios, scores, or boolean flags.
average_order_value = total_revenue / order_count
is_high_value = lifetime_value > 1000Computed Attribute Properties
Every computed attribute has these core properties:
| Property | Description |
|---|---|
| Name | Human-readable label displayed in the UI and available for audience building |
| Slug | URL-safe identifier used in the API to reference the computed attribute |
| Entity Type | The entity type this computed attribute is computed for (e.g., User, Account) |
| Data Type | The output type: string, number, boolean, date, or timestamp |
| Type | SQL, Aggregation, or Formula |
How Computed Attributes Are Used
Once computed, computed attributes are available throughout Activation:
- Audience conditions — Filter customers by computed attribute values (e.g.,
lifetime_value > 500) - Formula inputs — Reference computed attributes in formula expressions to derive new metrics
- Audience sync fields — Include computed attribute values as fields sent to destinations
- Insights — Track computed attribute distributions and trends over time
Computed Attribute Evaluation
Computed attributes are evaluated on read: Zeotap generates SQL and runs it against your warehouse whenever the attribute is referenced, so results always reflect your latest data and definition. Dependency ordering (formula computed attributes that depend on other computed attributes) is resolved as part of that same on-read computation.
Next Steps
- SQL Computed Attributes — Write custom SQL for maximum flexibility
- Aggregation Computed Attributes — Use the visual builder for common metrics
- Formula Computed Attributes — Combine existing computed attributes with expressions
- Computed Attribute Evaluation — Understand how and when computed attributes are evaluated