You can use formulas to create complex calculations of form fields values.
CAUTION: Do not remove the equals sign
(=) from the formula. Without it, the value is treated as text instead
of being evaluated.
The following form items can be referenced:
| Form item | Syntax | Example |
|---|---|---|
| Form field | ${field.<field-id>} | ${field.Quantity} |
| Form variable | ${variable.<variable-name>} | ${variable.TaxRate} |
| Field in a repeatable section | ${field.<section-id>.<field-id>} | ${field.POItems.UnitPrice} |
| Repeatable section | ${field.<section-id>} | ${field.POItems} |
Note:
The reference uses an item's ID, not its displayed label. For repeatable-section fields, the reference contains both the repeatable section ID and the child field ID.
For example, the following formula adds tax value from a form variable to a subtotal field:
=${field.Subtotal} + ${variable.TaxAmount}
The following arithmetic operators can be used in formulas:
| Operator | Operation | Example |
|---|---|---|
| + | Addition | =${field.Subtotal} + ${field.Tax} |
| - | Subtraction | =${field.Total} - ${field.Discount} |
| * | Multiplication | ${field.POItems.UnitPrice} |
| / | Division | =${field.Total} / ${field.ItemCount} |
| % | Remainder | =${field.ItemCount} % 2 |
| ^ | Exponent | =${field.Value} ^ 2 |
Note: When * and / operators are
used in a formula that reads values from repeatable section fields, the result is
written outside of that section. For more information, see Calculating Field Values Across Repeating Sections.
You can use parentheses to control evaluation order:
=(${field.Subtotal} - ${field.Discount}) * ${field.TaxRate}
You can use condition ? valueIfTrue : valueIfFalse for a conditional value:
=${field.Subtotal} >= 1000 ? ${field.Subtotal} * 0.1 : 0
The following are common functions that you can use in your calculations:
| Function | Description | |
|---|---|---|
| round(value, precision) | Rounds a value to the specified number of decimal places. | =round(${field.Subtotal} * 0.08, 2) |
| floor(value) | Rounds a value down to the nearest integer. | =floor(${field.TotalHours} / 8) |
| ceil(value) | Rounds a value up to the nearest integer. | =ceil(${field.ItemCount} / 10) |
| abs(value) | Returns the absolute value. | =abs(${field.ProjectedCost} - ${field.ActualCost}) |
| min(values) | Returns the lowest value. | =min(${field.POItems.UnitPrice}) |
| max(values) | Returns the highest value. | =max(${field.POItems.UnitPrice}) |