- 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

🎯 Design Note: The sum() function adds up all numeric values extracted from your data.


What does the sum formula do?

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.

graph LR A["Input: Values"] --> B["sum()"] B --> C["Result: Total Sum"]

Examples

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

Example 1: JSON Message Body

Input - Example 1

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

Formula Expression - Example 1

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

Result - Example 1

4

Example 2: Plain Text Body

Input - Example 2

2

Formula Expression - Example 2

sum(body)

Result - Example 2

2

simpleBody

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


Example 3: Message Context Value

Input - Example 3

4

Formula Expression - Example 3

sum(context('id'))

Result - Example 3

4

messageContext

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


Example 4: JSON with Nested Formula

Input - Example 4

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

Formula Expression - Example 4

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

Result - Example 4

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.


How to use the sum formula

Syntax

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

Next step