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

# avg

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

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

<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 }
```
