Contact Us 1-800-596-4880

avg

avg(values: Array<Number>): Number

Returns the average of numbers listed in an array.

An array that is empty or that contains a non-numeric value results in an error.

Parameters

Name Description

values

The input array of numbers.

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 }