Computed Fields
Create fields that automatically calculate their value based on formulas using other field values.
Formula Syntaxโ
Use field paths in your formulas to reference other field values. Basic arithmetic operators (+, -, *, /) are supported.
// Total calculation
price * quantity
// With discount
price * quantity * (1 - discountRate)
// String concatenation
firstName + " " + lastName
Output Typesโ
When creating a computed field, specify the output type:
- Number - For mathematical calculations
- String - For text concatenation
- Boolean - For true/false results
Examplesโ
Price Calculationโ
// Subtotal
unitPrice * quantity
// With tax
unitPrice * quantity * 1.08
// With discount and tax
unitPrice * quantity * (1 - discount) * (1 + taxRate)
String Operationsโ
// Full name
firstName + " " + lastName
// Full address
street + ", " + city + ", " + state + " " + zipCode
Boolean Logicโ
// Check if over limit
total > 1000
// Check if complete
firstName && lastName && email
Creating a Computed Fieldโ
- Add a Computed field type to your form
- Set the Label for display
- Enter the Formula using field references
- Select the Output Type (number, string, boolean)
- Configure Display Options (decimal places, format)
Available Functionsโ
Math Functionsโ
- Basic arithmetic:
+,-,*,/ - Modulo:
% - Parentheses for order of operations
String Functionsโ
- Concatenation with
+ - Template literals with field references
Comparison Operatorsโ
==,!=- Equality>,<,>=,<=- Comparisons&&,||- Logical AND/OR
Field Referencesโ
Reference other fields by their path:
// Simple field
fieldName
// Nested field
address.city
// Array field (first item)
items[0].price
warning
Computed fields are read-only and recalculate automatically when their dependencies change.
Display Configurationโ
Number Formattingโ
- Decimal Places - Number of decimals to show
- Currency Format - Display as currency
- Percentage - Display as percentage
Visibilityโ
- Show in Form - Display to users
- Hidden - Calculate but don't show
- Read-only - Always true for computed fields
Use Casesโ
- Order Totals - Sum line items, apply discounts
- Full Names - Combine first and last names
- Age Calculation - Calculate from birth date
- Progress Percentage - Calculate completion
- Running Totals - Cumulative calculations
Best Practicesโ
- Keep formulas simple - Break complex calculations into steps
- Handle edge cases - Consider null/undefined values
- Test thoroughly - Verify calculations with different inputs
- Document formulas - Add help text explaining the calculation
- Consider performance - Complex formulas may slow the form
Troubleshootingโ
Field showing NaN:
- Check that referenced fields have numeric values
- Verify field paths are correct
Calculation not updating:
- Ensure dependency fields are correctly referenced
- Check for circular dependencies
Wrong result:
- Verify order of operations
- Test with known values
Next Stepsโ
- Field Configuration - Configure field properties
- Form Variables - Use variables in forms
- Conditional Logic - Show fields based on calculations