Computed Fields

Automatically calculate form values using CEL formulas for scoring, totals, and derived data.

Advanced
4 min read

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 CaseExample Formula
Scoringrecord.data.q1 + record.data.q2 + record.data.q3
Totalsrecord.data.subtotal * 1.1 (add 10% tax)
Categorizationrecord.data.score >= 10 ? "High" : "Low"
Age calculationnow.year - record.data.birth_year

Creating a Computed Field

  1. Go to Data Types in your workspace
  2. Select a form or create a new one
  3. Click Add Field
  4. Choose Formula as the field type
  5. Enter your CEL expression in the Formula box
  6. Save the form

Writing Formulas

Basic Syntax

Reference other fields using record.data.<field_slug>:

cel

Available Variables

VariableDescriptionExample
record.data.<slug>Any field value from this formrecord.data.score
member.nameMember's namemember.name
member.labelsMember's labels"vip" in member.labels
now.yearCurrent yearnow.year
now.monthCurrent month (1-12)now.month
now.dayCurrent day of monthnow.day
now.hourCurrent hour (0-23)now.hour

Operators

TypeOperatorsExample
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

  1. No circular references - A computed field cannot reference another computed field
  2. No external data - Formulas can only use fields from the same form
  3. Missing values default to 0 - If a referenced field is empty, it's treated as 0
  4. 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.

  • Knowledge - Creating and managing forms
  • Actions - CEL syntax reference for conditions