Using Calculated Fields
What Are Calculated Fields?
Calculated fields perform automatic math operations using values from other fields in your form. They update in real time as respondents fill out the form, allowing you to display dynamic totals, scores, and computed values without any coding.
Adding a Calculated Field
- In the form editor, click Add Field and select Calculated Field from the field type list.
- Give the field a label (e.g., "Order Total" or "BMI Result").
- Click the Formula tab in the field settings to define your calculation.
Basic Math Operations
Calculated fields support the following operations:
- Addition (+): Add values together. Example:
Field1 + Field2 - Subtraction (-): Subtract one value from another. Example:
Price - Discount - Multiplication (*): Multiply values. Example:
Quantity * UnitPrice - Division (/): Divide one value by another. Example:
Total / NumberOfItems - Parentheses: Control order of operations. Example:
(Subtotal + Tax) * Quantity
Referencing Other Fields
To use another field's value in your formula:
- In the formula editor, click Insert Field or type
{to open the field picker. - Select the field you want to reference. It will be inserted into your formula as a field token (e.g.,
{Quantity}). - Build your formula using field tokens and math operators.
Fields you can reference:
- Number fields: Use the numeric value directly.
- Choice fields with numeric values: If you assign numeric values to dropdown or radio options, those values can be used in calculations.
- Other calculated fields: Chain calculations by referencing one calculated field inside another.
Displaying Calculations
Configure how the calculated result appears to respondents:
- Number Format: Choose the number of decimal places (e.g., 2 for currency).
- Prefix: Add text before the value (e.g.,
$for currency). - Suffix: Add text after the value (e.g.,
kgor%). - Visibility: Choose whether the calculated field is visible to respondents or hidden (used only for internal logic or passed to integrations).
Use Cases
Order Total Calculator
Build an order form where customers select products and quantities. Use calculated fields to show line item totals and a grand total:
- Line Total:
{Quantity} * {UnitPrice} - Subtotal:
{LineTotal1} + {LineTotal2} + {LineTotal3} - Tax:
{Subtotal} * 0.08 - Grand Total:
{Subtotal} + {Tax}
Score Calculator
Create a self-assessment where each answer has a point value. A calculated field sums up the points and shows a total score. You can use this with conditional logic to display different messages based on the score range.
BMI Calculator
Ask for height and weight, then calculate BMI using the formula: {Weight} / ({Height} * {Height}). Add a prefix and suffix to format the output as needed.
Pricing Estimator
Let potential customers configure options (size, add-ons, duration) and see an estimated price update in real time. This is great for service businesses, SaaS pricing pages, or custom product configurators.
Tips and Limitations
- Division by zero: If a divisor field is empty or zero, the calculated field displays "N/A" instead of an error.
- Empty fields: Empty number fields are treated as 0 in calculations.
- Circular references: You cannot create a formula that references itself. WittyForm will show an error if a circular reference is detected.
- Calculation order: When one calculated field references another, WittyForm automatically resolves them in the correct order.
- Submission data: Calculated field values are included in form submissions, exports, and integrations.