The Math steps do arithmetic without a Code step: an order's total with tax, a 10% discount, a price rounded to two decimals, or 149900 shown as $149,900.00. Each one is its own step, and none needs a connection.

Who can do this

Workspace Admins and Editors, on every plan.

The steps

Step What it does
Calculate Works out a sum with values from earlier steps: + − × ÷ (or * and /), brackets, 20% for a percentage, 10 % 3 for a remainder, and round, min, max, abs.
Round a number To a number of decimal places — Nearest, Up or Down.
Random number Picks a number between two others — whole, or with decimals.
Format a number Writes a number with grouping, decimals and a currency symbol, as text for an email or a message.

Steps

  1. Select + where the number is needed. In the step picker, open Utilities, select Math — No connection needed — then the step. Or search for the step's name.
  2. For Calculate, type the sum in Expression, dragging in values from Data from earlier steps — for example {{ $json.price }} * {{ $json.quantity }} * 120%. For Round a number and Format a number, put the value in Number. For Random number, set From and To — 1 and 100 unless you change them.
  3. Fill in the step's own settings:
    • Round a number — Decimal places (0 unless you change it) and Round: Nearest (the default), Up or Down.
    • Random number — Whole numbers only, on unless you turn it off.
    • Format a number — Decimal places (2 unless you change it); Grouping: International · 149,900.00 (the default), Space · 149 900,00, Dot · 149.900,00, Indian · 1,49,900.00 or None · 149900.00; and Currency symbol — optional, such as $, €, £ or ₹, written in front: $149,900.00.
  4. In Put the result in, keep the suggested field name or type your own. The item's other fields are kept.
  5. Select Run this step, then check Output.

Output

The result goes under the field you named — by default result. Every other field on the item is kept; a field already called that is replaced. Calculate, Round a number and Random number give a number, without trailing zeros — 1798.8, not 1798.80. Format a number gives text, so use it last, after the arithmetic.

Good to know

  • Calculate is arithmetic only. It cannot read files, call addresses or run code; anything other than numbers, the signs above and the four functions stops the step with what it found. For more, use the Code step.
  • % does two things. After a number with nothing following it is a percentage — {{ $json.amount }} * 18% is 18 percent of the amount. Between two numbers it is the remainder — 10 % 3 is 1.
  • round(x, 2) rounds to two places; round(x) to a whole number. min and max take as many values as you give them.
  • Values in Calculate must be plain numbers, such as 1499 or 1499.50. A value written with a thousands separator or a currency symbol — 1,499.00, $1499 — stops the step. Round a number and Format a number read 1,499.00 and 1e3 as well.
  • Money is worked out in decimals, not floating point, so 0.1 + 0.2 gives 0.3.
  • Nearest rounds halves away from zero: 2.5 becomes 3, and -2.5 becomes -3. Up and Down go towards the larger and the smaller number: -2.5 rounded Down is -3.
  • Random number includes From and To. With Whole numbers only off, it gives up to six decimal places.
  • It runs once per item.

If something goes wrong

What the run says Why What to do
The expression can't be worked out: …. It takes numbers, + − × ÷, brackets, %, round, min, max and abs. Something in Expression is not a number, a sign or a function — the middle says what. it ends too soon — a value may be empty means a value from an earlier step was empty. Check the step's Input; give an empty value a default with Set / Edit Fields, or correct the expression.
The expression divides by zero. / The expression takes a remainder by zero. The divisor was 0 for this item. Add an IF before the step to handle 0.
Expression is empty when the step ran — an earlier step may not have given the value it names. (or Number, From, To) The box is empty, or names a value the item does not have. Fill it in, or correct the value in {{ }}.
Number “…” is not a number. (or From, To) The value is text that is not a number. Check the value from the earlier step.
Decimal places “…” is not a whole number from 0 to 10. Decimal places is out of range. Use a whole number from 0 to 10.
To is smaller than From. Random number's To is below From. Swap them.
There is no whole number between From and To. Whole numbers only is on and the range holds none, such as 1.2 to 1.8. Widen the range, or turn Whole numbers only off.