Skip to content
Documentation
Updated 3 minutes to read
Markdown

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)
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 returns the unrounded average 340.9333333333333333333333333.

max(content [, unique])
Parameter Required Description
content ✅ Yes The numeric values to compare: body, 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.
  • 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).

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

Example 1: Highest order amount in an XML message

Section titled “Example 1: Highest order amount in an XML message”

Message Body:

<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>
max(xPath('Orders/Order/Amount', body))
666

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

Example 2: Highest value extracted from JSON

Section titled “Example 2: Highest value extracted from JSON”

Message Body:

{"a":[{"b":"1337"},{"b":"8"},{"b":"42"}]}
max(jsonPath('a[*].b', body))
1337

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

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

Section titled “Example 3: Highest value in a CSV column stored in message context”

Message Context:

Key Value
Ids the CSV text below
"face","suit","value"
"king","spades","13"
"queen","spades2","12"
#"jack","spades3","666"
"ten","spades4","10"
max(csv(1, ',', 2, '#', context('Ids')))
13

Test Expression with max(csv(1,',',2,'#',context('Ids'))) on CSV text in the context key Ids, returning 13 (7.12)
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

Section titled “Example 4: Longest value extracted from JSON”

Message Body:

{a:[{b:'This'},{b:'is'},{b:'Formula Plugin'}]}
max(length(jsonPath('a[*].b', body)))
14

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

...

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