Link Menu Expand (external link) Document Search Copy Copied

Evaluate Math Expression

Definition

The Evaluate Math Expression action calculates a numeric formula in a single step. Combine numbers, named variables, arithmetic operators, parentheses, and supported math functions.

For example, round((1 + 29) / 3) returns 10.

Use this action for calculations such as an average score, a rounded quantity, or an amount shared between participants. For a single calculation between two numbers, you can also use Perform Maths Operation.

Inputs

Expression

Enter the formula to calculate. This field is required.

round((subtotal + tax) / participants, 2)

Use a period for decimal numbers, such as 1.5, and commas to separate function arguments. Do not include currency symbols or thousands separators in numeric literals. These rules apply regardless of the Culture setting.

You can enter a fixed formula or use tokens. For numbers from earlier steps, add named variables and reference their names in the formula. This avoids inserting formatted text into the expression.

Variables

Variables are optional. Click Add variable for each numeric value used by the formula, then provide:

  • Variable name: a unique name, such as subtotal or participants.
  • Variable value: a number entered directly or a numeric token selected from an earlier step.

Names must start with an English letter or underscore and contain only English letters, digits, or underscores. Spaces and hyphens are not allowed. Names are case-sensitive: total and Total are different variables.

Supported function names and the names true, false, and null are reserved, regardless of capitalization. You can add up to 64 variables. Use Remove variable to delete an entry you no longer need.

Format

An optional number format for the Formatted number output. If left blank, the action uses the general format, G.

Format Purpose Example with result 1234.5 and culture en-US
G General numeric text 1234.5
N2 Group separators and two decimal places 1,234.50
F2 Two decimal places without group separators 1234.50
C2 Currency with two decimal places $1,234.50

Formatting changes the text output only. To round the numeric Result, use round() in the expression. The format can contain at most 32 characters; precision in a standard format such as N2 cannot exceed 99. Integer-only formats such as hexadecimal X are not supported for this action’s floating-point result.

Culture

An optional culture code for formatting the output, such as en-US, en-AU, or de-DE. If left blank, it defaults to en-US.

For example, result 617.25 with format N2 becomes 617.25 in en-US and 617,25 in de-DE. Culture changes the output’s regional formatting; it does not change the expression syntax.

Supported Operators

Operator Purpose Example Result
+ Addition 3 + 5 8
- Subtraction or negative sign 3 - 5 -2
* Multiplication 3 * 5 15
/ Division 1 / 2 0.5
% Remainder 17 % 5 2

Multiplication, division, and remainder are evaluated before addition and subtraction. Use parentheses to control the order: 2 + 3 * 4 returns 14, while (2 + 3) * 4 returns 20.

A nonzero remainder has the same sign as the first number: -17 % 5 returns -2. Use pow(x, y) for powers; ^ is not supported.

Supported Functions

Function names are case-insensitive. For example, round, Round, and ROUND refer to the same function. Functions can be nested.

Function Purpose Example Result
round(x) Round to a whole number round(2.5) 3
round(x, places) Round to the specified decimal places round(1.235, 2) 1.24
floor(x) Round down floor(-2.3) -3
ceil(x) or ceiling(x) Round up ceil(2.3) 3
truncate(x) Remove the fractional part toward zero truncate(-2.9) -2
abs(x) Absolute value abs(-5) 5
min(x, y) Smaller of two values min(3, 8) 3
max(x, y) Larger of two values max(3, 8) 8
pow(x, y) Raise x to power y pow(2, 3) 8
sqrt(x) Square root sqrt(25) 5

For round, the number of decimal places must be a whole number from 0 to 15. If omitted, it is 0. Midpoints round away from zero: round(2.5) returns 3 and round(-2.5) returns -3.

min, max, and pow take exactly two arguments. The other functions take one, except round, which accepts one or two.

Outputs

Output Type Use
Result (result) Number Pass to another calculation or use in a condition.
Formatted number (formattedResult) Text Insert into an email, document, or other text field using the selected Format and Culture.

Example Use Cases

  • Calculate an average score: use round(totalScore / assessmentCount, 2) with numeric values from earlier steps.
  • Estimate required packages: use ceil(itemCount / itemsPerPackage) to round a package count up to a whole number.
  • Apply a maximum allowance: use min(requestedAmount, allowance) to select the smaller amount.
  • Share a total between participants: use round(total / count, 2) to calculate a rounded amount per participant.

Example

Scenario: Calculate the amount per participant from numeric values collected earlier in a flow.

  1. Add Evaluate Math Expression to the flow and open its settings.
  2. Enter round(total / count, 2) in Expression.
  3. Add a variable named total and select the total amount token as its value.
  4. Add a variable named count and select the participant count token as its value. Ensure the count is greater than zero.
  5. Enter N2 in Format and de-DE in Culture.
  6. Use Result in a later calculation, or Formatted number in an email.

If total is 1234.5 and count is 2, the numeric result is 617.25 and the formatted number is 617,25.

When splitting monetary amounts, rounding each share can leave a difference from the original total. If every cent must be allocated, account for that difference separately.

Best Practices

  • Bind numeric values as variables. Keep the formula readable and avoid inserting currency symbols or regionally formatted text into it.
  • Use Result for calculations. Use Formatted number when inserting the value into an email or document.
  • Check divisors before running the action. Ensure participant counts, package sizes, and other divisors are not zero.
  • Choose rounding deliberately. Use round to change the numeric result; use Format to control its appearance as text.
  • Test with representative values. Include zeros, negative numbers, decimal values, and the largest values your flow expects.

Limits and Troubleshooting

The action supports numeric formulas using only the operators and functions listed above. It does not run C# or JavaScript code, comparisons, conditional expressions, or text formulas.

Limit Maximum
Expression length 2048 characters
Expression tokens (numbers, names, operators, and punctuation) 256
Nested parentheses 32 levels
Expression structure depth, including nested operators and functions 64 levels
Variables 64
Decimal places passed to round 15
Format length 32 characters
Precision in a standard output format 99

If the action fails, check the following:

  • Invalid expression: check parentheses, commas, and the number of function arguments. Use * for multiplication, such as 2 * total.
  • Undefined variable: add a variable with the exact name used in the formula, including capitalization.
  • Invalid variable value: supply a numeric value rather than formatted text, a collection, or an empty value.
  • Unsupported function or operator: use only those listed above. For example, use pow(2, 3) instead of 2 ^ 3.
  • Invalid rounding precision: use a whole number from 0 to 15. Negative or fractional decimal places are rejected.
  • Non-finite result: check for division by zero, square roots of negative values, and numbers too large to represent. Results such as infinity or an undefined numeric value are rejected.
  • Invalid format or culture: try N2 with en-US, then adjust the settings as needed.
  • Expression too complex: simplify the formula or split the calculation across several actions.

Calculations use double-precision floating-point numbers. Small decimal rounding differences are possible, and requesting more display digits does not increase calculation accuracy. Use a calculation method designed for exact decimal arithmetic when your workflow requires exact monetary or accounting results.