Skip to content
Documentation
Updated 3 minutes to read
Markdown

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.

round around avg in a Search Field Expression, tested on an order with three lines, animated walkthrough (7.12)
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).

round(content, decimals)
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.

  • Every numeric value in content, each rounded on its own to decimals decimals. Several values in give several values out.
  • A midpoint is rounded away from zero: 2.5 → 3, -2.5 → -3, and 2.345 with 2 decimals → 2.35.
  • The value isn't padded: 1.5 rounded to 2 decimals stays 1.5, and trailing zeros already in a value stay (399.80 with 2 → 399.80).
  • A value that isn't a number is dropped, as with avg, min, and max. When nothing numeric is left, round returns 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.

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>
round(avg(xPath('OrderEntry/OrderLines/OrderLine/LineTotal', body)), 2)
340.93

xPath 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.

Test Expression tab: round of the average of the order line totals, with 2 decimals, returns 340.93 (7.12)
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 } ] }
round(jsonPath('a[*].b', body), 0)
3
-3
1

Test Expression tab: round of every b in the array a, with 0 decimals, returns 3, minus 3, and 1 (7.12)
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 0 to 28 are 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.

...

Version:
Release date: N/A
Loading...

Explore Nodinite for 30 days – completely free

  • Find out why this is the leading O&M software
  • Prove your business case
  • Test the self-service for the business side

Loading...

See how Nodinite resolves your technical issues, in a LIVE Demo!

Once you submit this request:

  • We will give you a short call to understand the issues you want to tackle.
  • Understand solutions you have tried and why were you not happy with them.
  • Book a convenient slot for a LIVE demo!

Loading...