---
schema_version: "1"
id: 549af5cf245288dc92002c784830a331d722dfd82e90c8bba8da292253bd8257
title: avg
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-core-functions-avg.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-core-functions-avg
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 64db76a3391a58433fd1bff51b422b8ee7770c6190b61160c4b0e21525e81603
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# avg

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## avg(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

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>values</code></p></td><td><p>The input array of numbers.</p></td></tr></tbody></table>

### Example

This example returns the average of multiple arrays.

#### Source

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

#### Output

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