- Docs
- Conditional Logic
- Field Calculations
Calculated fields turn your forms into interactive tools. Instead of collecting raw data and crunching numbers later, you can compute totals, scores, and dynamic values right inside the form as the respondent fills it out. Build pricing calculators, quiz scoring systems, order forms with running totals, and ROI estimators β all without writing a single line of backend code.
How Calculated Fields Work
A calculated field is a special field type that displays a computed value instead of accepting user input. You define a formula that references other fields in your form, and BttrForm evaluates it in real time as the respondent enters data. The computed result updates instantly, giving respondents immediate feedback.
To add a calculated field, open the field palette in the form builder and drag the "Calculation" field type onto your form. Click it to open the formula editor.
Display Only
Calculated fields are read-only for respondents. They display the result but cannot be edited. The computed value is included in the form submission alongside all other field data.
Formula Syntax
BttrForm formulas use a straightforward syntax that supports arithmetic operations, built-in functions, and field references.
Referencing Fields
Reference other fields by wrapping the field's variable name in curly braces. You can find and set a field's variable name in its settings panel under "Variable Name."
{quantity} * {unit_price}
Arithmetic Operators
| Operator | Description | Example |
|---|---|---|
+ | Addition | {subtotal} + {tax} |
- | Subtraction | {total} - {discount} |
* | Multiplication | {hours} * {rate} |
/ | Division | {total} / {num_people} |
% | Modulo | {value} % 2 |
( ) | Grouping | ({price} + {tax}) * {qty} |
Built-In Functions
BttrForm provides a library of functions for common calculations:
// Rounding
round({total}, 2) // Round to 2 decimal places
ceil({shipping_weight}) // Round up to nearest integer
floor({discount_pct}) // Round down to nearest integer
// Aggregation
sum({item1}, {item2}, {item3}) // Sum of values
avg({score1}, {score2}) // Average of values
min({bid1}, {bid2}, {bid3}) // Minimum value
max({rating1}, {rating2}) // Maximum value
// Conditional
if({age} >= 18, "Adult", "Minor") // If-then-else
if({total} > 100, {total} * 0.9, {total}) // 10% discount over $100
// Text
concat({first_name}, " ", {last_name}) // Join text
length({comment}) // Character count
Pro Tip
The formula editor provides autocomplete for field names and functions. Start typing { to see a list of available fields, or type a function name to see its signature and description.
Practical Examples
Example 1: Order Form with Running Total
Build an order form where the total updates as the customer selects items and quantities.
Fields:
product_priceβ Dropdown with values: Basic ($29), Pro ($79), Business ($199)quantityβ Number field (min: 1, max: 100)discount_codeβ Text field (optional)
Calculated Fields:
// Subtotal
{product_price} * {quantity}
// Discount (10% if code is "SAVE10", otherwise 0)
if({discount_code} == "SAVE10", {subtotal} * 0.10, 0)
// Tax (8.5%)
({subtotal} - {discount}) * 0.085
// Grand Total
round({subtotal} - {discount} + {tax}, 2)
The respondent sees the subtotal, discount, tax, and grand total update instantly as they change their selections.
Example 2: Quiz Scoring
Create a self-grading quiz that shows the respondent their score at the end.
Fields:
q1β Radio: "What is 2 + 2?" (Options: 3, 4, 5)q2β Radio: "Capital of France?" (Options: London, Paris, Berlin)q3β Radio: "Largest ocean?" (Options: Atlantic, Pacific, Indian)
Calculated Fields:
// Individual question scores
// Each correct answer = 1 point
{q1_score}: if({q1} == "4", 1, 0)
{q2_score}: if({q2} == "Paris", 1, 0)
{q3_score}: if({q3} == "Pacific", 1, 0)
// Total score
{total_score}: sum({q1_score}, {q2_score}, {q3_score})
// Percentage
{percentage}: round(({total_score} / 3) * 100, 0)
// Result message
{result}: if({percentage} >= 70, "Pass!", "Keep studying!")
Quiz Answer Visibility
By default, calculated fields are visible to respondents. If you are building a quiz and do not want to reveal the scoring logic, place the scoring calculations on a results page that appears after submission. Use skip logic to show the correct results page based on the score.
Example 3: Pricing Calculator
Let prospects estimate their monthly cost based on their expected usage.
Fields:
planβ Radio: Free, Pro ($29/mo), Business ($79/mo)extra_responsesβ Number: additional responses beyond plan limitextra_storageβ Number: additional storage in GB
Calculated Fields:
// Base price from plan selection
{base_price}: if({plan} == "Free", 0, if({plan} == "Pro", 29, 79))
// Overage costs
{response_cost}: max({extra_responses} - 1000, 0) * 0.01
{storage_cost}: max({extra_storage} - 1, 0) * 2
// Estimated monthly total
{monthly_total}: round({base_price} + {response_cost} + {storage_cost}, 2)
Formatting Calculated Results
By default, calculated fields display raw numbers. You can configure formatting in the field settings:
- Currency β prefix with $, EUR, or INR symbol and use two decimal places
- Percentage β append % and round to the nearest integer
- Number β set decimal places and thousand separators
- Text β display the result as plain text (useful for conditional messages)
Select the appropriate format in the "Display Format" dropdown of the calculated field's settings panel.
Chaining Calculations
Calculated fields can reference other calculated fields, allowing you to build complex computation chains. BttrForm automatically determines the evaluation order based on dependencies.
{subtotal}: {quantity} * {unit_price}
{tax}: {subtotal} * 0.085
{shipping}: if({subtotal} > 50, 0, 9.99)
{grand_total}: {subtotal} + {tax} + {shipping}
Avoid Circular References
If Field A references Field B and Field B references Field A, you have a circular reference. BttrForm detects these and displays an error in the formula editor. Break the cycle by restructuring your formulas.
Using Calculations in Logic Rules
Calculated field values can be used as conditions in both show/hide rules and skip logic. This is powerful for scenarios like:
- Show a "Volume Discount" message when the calculated subtotal exceeds $500
- Skip to a "Premium Support" page when the selected plan's calculated price is above $100
- Hide the checkout page when the grand total equals zero (free tier, no overages)
Troubleshooting
Formula shows NaN: A referenced field is empty or contains non-numeric text. Wrap the reference in a fallback: if({field} == "", 0, {field}).
Decimal precision issues: Floating-point math can produce results like 29.990000000001. Use round({result}, 2) to clean up display values.
Calculation not updating: Ensure the source fields have variable names assigned. Fields without variable names cannot be referenced in formulas.
Was this helpful?