Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

avg

avg(Array<Number>): Number

Creates an average of all the values in an array and outputs a single number. The array must of course contain only numerical value in it.

Transform

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

        
     
1
2
3
4
{
  "a": 500.5,
  "b": 2.0
}