Computed Fields
Automatically calculate form values using CEL formulas for scoring, totals, and derived data.
Computed Fields
Computed fields automatically calculate their values from other fields using formulas. Use them for scoring, totals, and derived values without manual data entry.
What are Computed Fields?
A computed field is a special field type that:
- Calculates automatically - Values are computed when the form is saved
- Updates on change - Recalculates whenever dependent fields change
- Cannot be edited directly - Users can't override the formula result
- Uses CEL expressions - Write formulas using Common Expression Language (CEL)
Common Use Cases
| Use Case | Example Formula |
|---|---|
| Scoring | record.data.q1 + record.data.q2 + record.data.q3 |
| Totals | record.data.subtotal * 1.1 (add 10% tax) |
| Categorization | record.data.score >= 10 ? "High" : "Low" |
| Age calculation | now.year - record.data.birth_year |
Creating a Computed Field
- Go to Data Types in your workspace
- Select a form or create a new one
- Click Add Field
- Choose Formula as the field type
- Enter your CEL expression in the Formula box
- Save the form
Writing Formulas
Basic Syntax
Reference other fields using record.data.<field_slug>:
cel
Available Variables
| Variable | Description | Example |
|---|---|---|
record.data.<slug> | Any field value from this form | record.data.score |
member.name | Member's name | member.name |
member.labels | Member's labels | "vip" in member.labels |
now.year | Current year | now.year |
now.month | Current month (1-12) | now.month |
now.day | Current day of month | now.day |
now.hour | Current hour (0-23) | now.hour |
Operators
| Type | Operators | Example |
|---|---|---|
| Math | + - * / | record.data.a + record.data.b |
| Comparison | == != < > <= >= | record.data.score >= 10 |
| Logic | && || ! | record.data.a > 5 && record.data.b > 5 |
| Conditional | ? : | record.data.score >= 15 ? "High" : "Normal" |
Examples
GAD-7 Anxiety Scoring
The GAD-7 is a 7-question anxiety screening with scores 0-3 per question:
cel
Score Interpretation
Add another computed field to interpret the score:
cel
BMI Calculator
Calculate BMI from height (inches) and weight (pounds):
cel
Days Until Birthday
Calculate days remaining (simplified - uses year only):
cel
Limitations
- No circular references - A computed field cannot reference another computed field
- No external data - Formulas can only use fields from the same form
- Missing values default to 0 - If a referenced field is empty, it's treated as 0
- No string operations - Limited to basic CEL string functions
Troubleshooting
"References unknown field"
The field slug in your formula doesn't exist. Check:
- The field slug is spelled correctly (case-sensitive)
- The field exists in this form (not a different form)
- You're using
record.data.prefix
"Cannot reference another function field"
You tried to reference one computed field from another. Computed fields can only reference regular (non-computed) fields.
Formula returns wrong value
- Check field types - Ensure numeric fields are defined as Number/Integer, not Text
- Check for nulls - Empty fields become 0, which may affect calculations
- Test with simple values - Try hardcoding numbers to isolate the issue
Field Validation
Beyond computed fields, CEL can also be used to validate user input. Fields support a validateCel property that enforces custom validation rules before data is saved. Use validation to ensure dates are in the future, values fall within acceptable ranges, or any other business logic your forms require. For detailed syntax and examples, see the CEL Reference Guide.
Related
Related Resources
Forms
Create structured data types to collect, store, and manage information through AI-powered conversations or manual entry.
Files
Upload, organize, and share documents, images, and files with folder hierarchies and access controls.
Labels
Organize members, chats, and files with color-coded tags for filtering, automations, and access control.
All Guides
Browse all available guides