Skip to content

Calculations

Calculation fields let you display a value computed from the visitor's answers. They are useful for quote builders, quantity totals, service estimates, scores, fees, and payment amounts that depend on several fields.

The browser updates the result as the visitor fills out the form. On submission, NXP Easy Forms recalculates the value on the server from the saved formula and validated input. A visitor cannot change the authoritative result by editing the page or posting a different calculation value.

Create a calculation

  1. Open the form in the builder.
  2. Add a Calculation field from the field library.
  3. Set its label and field name in the basic settings.
  4. Open the calculation settings and build the formula.
  5. Choose the number format and display options.
  6. Check the preview, then save the form.

A Calculation field is output-only. Visitors do not type into it, and it does not have required-field validation of its own.

Build the formula

The safest way to reference a field is to use the Insert field buttons below the formula editor. The builder inserts a stable reference such as:

text
{ref:fld_01m0ceq9e43tpvv2tn4a6hrb99}

You can also type @ in the editor to search for a field. Use the inserted references rather than manually typing a field's internal name. The reference remains unambiguous when two fields have similar labels or when a label contains spaces.

For example, a quantity multiplied by a unit price looks like this:

text
{ref:fld_quantity} * {ref:fld_unit_price}

The fld_... values above are examples. Insert the actual references for the fields in your form.

Operators

The formula language supports:

OperatorMeaning
+Add
-Subtract or negate
*Multiply
/Divide
( )Group part of a formula

Functions

The following functions are available:

FunctionUse
min(a, b, ...)Return the smallest value
max(a, b, ...)Return the largest value
sum(a, b, ...)Add several values
avg(a, b, ...)Return the average
round(value, places)Round to a number of decimal places
floor(value)Round down
ceil(value)Round up
abs(value)Return the absolute value
if(condition, when_true, when_false)Choose between two results

The first argument of if() must be a comparison. Supported comparisons are ==, !=, <, <=, >, and >=.

Examples:

text
sum({ref:fld_design}, {ref:fld_printing}, {ref:fld_shipping})
text
round({ref:fld_subtotal} * 1.0825, 2)
text
if({ref:fld_quantity} >= 25, {ref:fld_subtotal} * 0.90, {ref:fld_subtotal})

Use a recipe

If you do not want to write the formula manually, select a recipe above the editor. The available recipes include:

  • Quantity times price
  • Subtotal plus tax percentage
  • Subtotal minus discount percentage
  • Volume tier discount
  • Sum of items
  • Round up to a batch size
  • Percentage fee or commission

The recipe dialog asks you to choose the relevant fields and enter any constants. Inserting a recipe replaces the current formula after confirmation, so copy or review an existing formula before accepting it.

Choose the display format

Calculation settings control how the result is displayed:

  • Decimal places: from 0 to 4.
  • Number format: plain, US, EU, or space-separated thousands formatting.
  • Prefix: optional text such as $ or From .
  • Suffix: optional text such as /month or points.

Prefix and suffix are presentation only. If the calculation is used for a payment, configure the payment currency separately in Form Settings -> Payments. Do not use a prefix as a substitute for the payment currency.

The read-only Resolved view below the editor replaces reference tokens with field labels, so you can check what the formula means without having to interpret generated field keys.

Supported input fields

A calculation can reference:

  • Number fields;
  • Range fields;
  • Rating fields;
  • Price fields;
  • other Calculation fields; and
  • a single-select Select field whose option values are all numeric.

For a Select field to be usable in a calculation:

  • multiple selection must be disabled;
  • it must contain at least one option; and
  • every option value must be a plain number with no more than four decimal places.

Examples of valid Select values are 750, 1500, 3000, and 19.99. The option label can remain human-friendly, such as Basic package, while its numeric value is used in the formula.

Text, email, telephone, checkbox, radio, date, file, and other non-numeric fields cannot be used as calculation operands. If a field is not offered by the Insert field picker, it is not eligible for the formula.

Payment amounts from calculations

To make a calculated total the payment amount:

  1. Add and configure the Calculation field.
  2. Confirm that its preview produces the expected total for representative inputs.
  3. Open Form Settings -> Payments and enable payments.
  4. Choose Calculation as the amount source.
  5. Select the Calculation field.
  6. Set the payment currency and provider settings.

The selected calculation is the authoritative amount. The payment pipeline evaluates it again on the server when checkout starts; it does not trust the calculated value posted by the browser.

If a calculation used for payment depends on a Number field, set a meaningful minimum and maximum on that Number field. The builder warns about unbounded numeric inputs because a visitor could otherwise submit an unexpectedly large or negative amount. Numeric Select fields are bounded by their configured options.

The provider's minimum charge still applies. A calculated result that is zero or below the provider minimum cannot start checkout. The visitor must choose inputs that produce a valid amount.

For payment forms, test all meaningful combinations, including zero quantities, the smallest and largest allowed values, decimal values, and any conditional branches in the formula.

Validation and troubleshooting

The form cannot be saved while a calculation has an invalid formula. Common messages mean:

MessageWhat to check
Field does not existReinsert the field using Insert field. The field may have been deleted or the token may belong to another form.
Unsupported operandUse a supported numeric field type. A Select must be single-choice with numeric option values.
Select operand is invalidTurn off multiple selection and check every option value for numeric syntax and decimal precision.
Calculation cannot reference itselfRemove the reference to the Calculation field currently being edited.
Calculations reference each other in a cycleMake the dependency chain one-way. A calculation may depend on an earlier calculation, but the chain must not loop back.
Formula is too complexSplit the work across multiple Calculation fields or simplify the expression.

When a field has been renamed, use the field picker again rather than relying on a manually typed label. When a referenced field is deleted, replace its reference before saving.

Calculation chains

Calculations can depend on other calculations. For example:

text
Subtotal = {ref:fld_quantity} * {ref:fld_unit_price}
Total = {ref:fld_subtotal} + {ref:fld_shipping}

Keep chains straightforward and avoid unnecessary intermediate fields. A calculation cannot reference itself, and two or more calculations cannot form a circular dependency. The builder and server validate the dependency graph when the form is saved.

AI-generated formulas

The Pro AI Assistant can propose calculation fields and formulas. Treat the proposal as a draft: verify the referenced fields, units, rates, rounding, and boundary cases before saving or binding the result to a payment. The server still validates and re-evaluates the saved formula.

License behavior

Calculation is a Pro field type. An active Pro license is required to add or edit calculation formulas. Existing saved calculations remain compatible with forms after a license lapse, but new Pro calculations and formula edits require the license to be active again.