---
title: Formula max – Highest Numeric Value in Nodinite Search Field Expressions
description: The max function in the Nodinite Formula plugin returns the highest numeric value in the content. Syntax, the unique parameter, and tested examples with xPath, jsonPath, csv in message context, and length.
---

# :fa-function: Formula - Max

The `max` function, one of the Math functions in the [Formula][] plugin for [Search Field Expressions][], returns the highest numeric value in the content.

![Lowest, highest, and average line total of an order with min, max, and avg, animated walkthrough (7.12)][5]  
*Animated walkthrough: on the Order Entry XML of order ORD-10011 in the [Order-to-Cash demo][], with the line totals 399.80, 498.00, and 125.00, [min][] returns `125.00`, `max` returns `498.00`, and [avg][average] returns the unrounded average `340.9333333333333333333333333`.*  

## :fa-code: Syntax

```text
max(content [, unique])
```

### Parameters

| Parameter | Required | Description |
| --- | --- | --- |
| `content` | ✅ Yes | The numeric values to compare: [body][], [context][Context], or another Formula function such as [xPath][], [jsonPath][], [csv][], or [length][]. |
| `unique` | ❌ No | Unquoted `true` or `false`; default `true` for this function. `false`: a value that appears several times counts every time. `true`: identical values count once. Values are compared as text, so `100` and `100.00` are different values. A quoted `'true'` is an error. |

### Returns

* One number: the highest numeric value in `content`.
* Values are compared as numbers, so `1337` is higher than `42` even when the values are JSON strings (see [Example 2](#example-2-highest-value-extracted-from-json)).

Quoting, nesting, and how `content` is resolved are described in the [Formula language rules][].

## :fa-list-ol: Examples

### Example 1: Highest order amount in an XML message

#### Input

Message Body:

```xml
<ns0:Orders xmlns:ns0="SupplyChain.Schemas/1.0">
  <Order>
    <Id>1337</Id>
    <Amount>666</Amount>
    <City>New York</City>
    <Partner>QWNtZQ==</Partner>
  </Order>
  <Order>
    <Id>1338</Id>
    <Amount>42</Amount>
    <City>Paris</City>
    <Partner>QWNtZQ==</Partner>
  </Order>
</ns0:Orders>
```

#### Formula

```text
max(xPath('Orders/Order/Amount', body))
```

#### Result

```text
666
```

![Test Expression with max(xPath('Orders/Order/Amount', body)) on an XML orders message, returning 666 (7.12)][1]  
*[xPath][] extracts the amounts `666` and `42`; the highest is `666`.*  

### Example 2: Highest value extracted from JSON

#### Input

Message Body:

```json
{"a":[{"b":"1337"},{"b":"8"},{"b":"42"}]}
```

#### Formula

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

#### Result

```text
1337
```

![Test Expression with max of jsonPath over every b in the array a, on a JSON array, returning 1337 (7.12)][2]  
*[jsonPath][] extracts `1337`, `8`, and `42`; the highest is `1337`.*  

### Example 3: Highest value in a CSV column stored in message context

#### Input

Message Context:

| Key | Value |
| --- | --- |
| `Ids` | the CSV text below |

```text
"face","suit","value"
"king","spades","13"
"queen","spades2","12"
#"jack","spades3","666"
"ten","spades4","10"
```

#### Formula

```text
max(csv(1, ',', 2, '#', context('Ids')))
```

#### Result

```text
13
```

![Test Expression with max(csv(1,',',2,'#',context('Ids'))) on CSV text in the context key Ids, returning 13 (7.12)][3]  
*[csv][] skips the header row, reads column `2` (the `value` column, counted from 0), and ignores the row that starts with `#`; the highest of `13`, `12`, and `10` is `13`.*  

### Example 4: Longest value extracted from JSON

#### Input

Message Body:

```text
{a:[{b:'This'},{b:'is'},{b:'Formula Plugin'}]}
```

#### Formula

```text
max(length(jsonPath('a[*].b', body)))
```

#### Result

```text
14
```

![Test Expression with max of the length of every b value in the JSON array a, returning 14 (7.12)][4]  
*[length][] returns `4`, `2`, and `14`; the highest is `14`, the length of `Formula Plugin`.*  

## :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-down-short-wide: [min][]  
* :fa-circle-half-stroke: [round][]  
* :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/max_XmlBody.png
[2]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Math/max_JSonBody.png
[3]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Math/MaxFromCSVContext.png
[4]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Math/MaxLenghJSONBodyString.png
[5]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Math/Formula_MinMaxAverage.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
[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
[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
[round]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Math/round.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