Contact Free trial Login

avg

avg(Array<Number>): Number

Returns the average of numeric values in a list (an array).

A list that is empty or that contains a non-numeric value results in an error.

Example

This example returns the average of multiple arrays.

Source

%dw 2.0
output application/json
---
{
  a: avg([1, 1000]),
  b: avg([1, 2, 3])
}

Output

{
  "a": 500.5,
  "b": 2.0
}

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub