Aggregate (Array Calculation Mapping)
The ArrayCalculationMapping is used to aggregate numerical values from a message field. It calculates the maximum, minimum, total, and average of the numbers found in the specified field. To define an array calculation mapping, ensure the function type is set to "Numeric functions" and the function is set to "aggregate".
The attributes that need to be set in an array calculation mapping are:
| Attribute | Required | Description |
|---|---|---|
| from | Y | Defines the source field name where the numbers are located. |
| to | Y | Defines the target field name where the results will be stored. |
| Function type | Y | Defines the type of mapping. Needs to be "Numeric functions". |
| Function | Y | Defines the mapping type. Needs to be "aggregate". |
Aggregation Results
The following values are calculated during aggregation and stored in the specified target path:
| Result | Description |
|---|---|
| max | The maximum value found in the array. |
| min | The minimum value found in the array. |
| total | The sum of all the values in the array. |
| avg | The average of the values in the array. |
Example
If an incoming message contains a field with an array of numbers
{
"numbers": [5.5, 12.3, 7.8, 3.0]
}
The mapping would aggregate the values as follows:
{
"results": {
"max": 12.3,
"min": 3.0,
"total": 28.6,
"avg": 7.15
}
}