---
title: Formula round – Round Numeric Values in Nodinite Search Field Expressions
description: The round function in the Nodinite Formula plugin rounds every numeric value to the given number of decimals, midpoints away from zero. Syntax, parameters, and tested examples with avg, xPath, and jsonPath.
---

# :fa-function: Formula - Round (round)

:new7.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)][1]  
*Animated walkthrough: the typical use. [avg][average] 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][Message Types] *O2C.Order.Entry/1.0*, checked on the **Test Expression** tab (see [Test Your Expression][]).*  

## :fa-code: Syntax

```text
round(content, decimals)
```

### Parameters

| Parameter | Required | Description |
| --- | --- | --- |
| `content` | ✅ Yes | The numeric values to round: [body][], [context][Context], or another Formula function, typically [avg][average], [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

* 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][average], [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][].

## :fa-list-ol: Examples

### Example 1: Round the average line total of an order

#### Input

Message Body:

```xml
<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

```text
round(avg(xPath('OrderEntry/OrderLines/OrderLine/LineTotal', body)), 2)
```

#### Result

```text
340.93
```

[xPath][] extracts the line totals `399.80`, `498.00`, and `125.00`. [avg][average] 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)][ex1]  
*The **Test Expression** tab with Example 1: one unique match, `340.93`.*  

### Example 2: Round several values, midpoints away from zero

#### Input

Message Body:

```json
{ "a": [ { "b": 2.5 }, { "b": -2.5 }, { "b": 1.4 } ] }
```

#### Formula

```text
round(jsonPath('a[*].b', body), 0)
```

#### Result

```text
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)][ex2]  
*[jsonPath][] extracts three values and `round` rounds each one: the midpoints `2.5` and `-2.5` go away from zero, to `3` and `-3`.*  

## :fa-circle-info: Notes

* 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`.

## :fa-hand-point-right: Next Steps

* :fa-magnifying-glass-plus: [Add or manage Search Field][]  
* :fa-flask: [Test Your Expression][]  
* :fa-hard-drive: [Add or manage Log View][]  

## :fa-link-horizontal: Related Topics

* :fa-calculator: [avg][average]  
* :fa-hashtag: [count][]  
* :fa-text-width: [length][]  
* :fa-arrow-up-wide-short: [max][]  
* :fa-arrow-down-short-wide: [min][]  
* :fa-plus: [sum][]  
* :fa-function: [Formula][]  
* :fa-scroll: [Formula language rules][]  
* :fa-puzzle-piece: [Search Field Expressions][]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Math/Formula_round.gif

[Add or manage Log View]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Add%20or%20Manage%20Log%20View.md
[Add or manage Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md
[average]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Math/average.md
[body]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/body.md
[Context]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/context.md
[count]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Math/count.md
[csv]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/csv.md
[ex1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Math/round_Example1.png
[ex2]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Math/round_Example2.png
[Formula]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md
[Formula language rules]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md#fa-scroll-formula-language-rules
[jsonPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/jsonPath.md
[length]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Math/length.md
[max]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Math/max.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[min]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Math/min.md
[Order-to-Cash demo]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Generate-O2C-Demo-Data.md
[Search Field Expressions]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md
[sum]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Math/sum.md
[Test Your Expression]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md#test-your-expression
[xPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/xPath.md