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

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