---
schema_version: "1"
id: 4ed2f9aeeb9591a1c7d38abbd5f2cc0c6b343b28016ca2182e565d845e23f97a
title: avg
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-core-functions-avg.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-core-functions-avg
source_site: docs.mulesoft.com
content_type: documentation
content_hash: de8ee272001d8335727190d2fc61bbcac19fecb13ed18fd46b3c22e3f44e6762
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

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