Formula - Round (round)
Section titled “ Formula - Round (round)”New 7.12 The round function, one of the Math functions in the Formula plugin for Search Field Expressions, returns every numeric value in the content rounded to the number of decimals you give, with midpoints rounded away from zero.

Animated walkthrough: the typical use. avg keeps up to 28 decimals, and round(…, 2) cuts the average line total of order ORD-10011 in the Order-to-Cash demo to 340.93. The expression is a Formula on the Message Type O2C.Order.Entry/1.0, checked on the Test Expression tab (see Test Your Expression).
Syntax
Section titled “ Syntax”round(content, decimals)Parameters
Section titled “Parameters”| Parameter | Required | Description |
|---|---|---|
content |
✅ Yes | The numeric values to round: body, context, or another Formula function, typically avg, sum, xPath, jsonPath, or csv. |
decimals |
✅ Yes | An unquoted whole number from 0 to 28: the number of decimals to keep. |
round has no unique argument: it doesn't aggregate, so the unique rule of the other Math functions doesn't apply.
Returns
Section titled “Returns”- Every numeric value in
content, each rounded on its own todecimalsdecimals. Several values in give several values out. - A midpoint is rounded away from zero:
2.5→3,-2.5→-3, and2.345with2decimals →2.35. - The value isn't padded:
1.5rounded to2decimals stays1.5, and trailing zeros already in a value stay (399.80with2→399.80). - A value that isn't a number is dropped, as with avg, min, and max. When nothing numeric is left,
roundreturns nothing. - The decimal separator is always
., whatever the culture of the server.
Quoting, nesting, and how content is resolved are described in the Formula language rules.
Examples
Section titled “ Examples”Example 1: Round the average line total of an order
Section titled “Example 1: Round the average line total of an order”Message Body:
<OrderEntry> <OrderId>ORD-10011</OrderId> <OrderLines> <OrderLine><Sku>SKU-1001</Sku><LineTotal>399.80</LineTotal></OrderLine> <OrderLine><Sku>SKU-2040</Sku><LineTotal>498.00</LineTotal></OrderLine> <OrderLine><Sku>SKU-3315</Sku><LineTotal>125.00</LineTotal></OrderLine> </OrderLines></OrderEntry>Formula
Section titled “Formula”round(avg(xPath('OrderEntry/OrderLines/OrderLine/LineTotal', body)), 2)Result
Section titled “Result”340.93xPath extracts the line totals 399.80, 498.00, and 125.00. avg returns 340.9333333333333333333333333 (1022.80 / 3), and round keeps two decimals. The walkthrough at the top of the page tests this example.

The Test Expression tab with Example 1: one unique match, 340.93.
Example 2: Round several values, midpoints away from zero
Section titled “Example 2: Round several values, midpoints away from zero”Message Body:
{ "a": [ { "b": 2.5 }, { "b": -2.5 }, { "b": 1.4 } ] }Formula
Section titled “Formula”round(jsonPath('a[*].b', body), 0)Result
Section titled “Result”3-31
jsonPath extracts three values and round rounds each one: the midpoints 2.5 and -2.5 go away from zero, to 3 and -3.
- Both arguments are required.
round(avg(...))without the decimals is a syntax error: Expected the number of decimals, for example round(avg(...), 2), found .... - Decimals outside
0to28are an error: round expects 0 to 28 decimals. - Midpoints round away from zero, not to the nearest even number (banker's rounding):
0.5→1,1.5→2,2.5→3.