- 2 minutes to read

Formula - Sum

Easily add up values from your data using the Sum Formula in Nodinite. This page provides clear, real-world examples with a new, easy-to-read layout that separates input, formula, and result.

✅ Instantly sum values from message body, Context, or nested formulas
✅ Use with JSON, XML, or plain text data
✅ Enhance your integration analytics with unique, reliable results


What is the Sum formula?

The sum() formula adds up all values extracted from your data. Use it to analyze message payloads, context values, or results from other formulas in your log views and search fields.


Syntax

  • From Message Body:
    sum(body)
  • From Message Context:
    sum(context('MessageContextKey'))
  • From Nested Formula:
    sum(SomeOtherFormula(Content))

Examples: Input, Formula, and Result

Below are practical examples showing exactly what input is used, the formula expression, and the resulting output.


Example 1: JSON Message Body

Input from Body

[{"value":1}, {"value":3}]

Formula

sum(jsonpath('$..value', body))

Result

4

Example 2: Plain Text Body

Input

2

Formula

sum(body)

Result

2

simpleBody
The result is 2 because the message body contains a single value.


Example 3: Message Context Value

Input

4

Formula

sum(context('id'))

Result

4

messageContext
The result is 4 because the context value for 'id' is a single value.


Example 4: JSON with Nested Formula

Input

{"a":[{"b":1},{"b":2},{"b":3}]}

Formula

sum(jsonpath('a[*].b', body))

Result

6

jsonpath
The result is 6 because the sum of 1, 2, and 3 is 6.


Features

  • Add up values from any Content
  • Works with JSON, XML, plain text, or any valid formula plugin
  • Returns the sum of all values
  • Ideal for integration analytics and data validation in Nodinite

Important: This plugin loads the entire message into RAM. For best performance, use it only on small messages.


Next Steps

Related Topics