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

# sum

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

## sum(Array<Number>): Number

Returns the sum of numeric values in an array.

Returns `0` if the array is empty and produces an error when non-numeric values are in the array.

### 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 sum of the values in the input array.

#### Source

```DataWeave
%dw 2.0
output application/json
---
sum([1, 2, 3])
```

#### Output

```JSON
6
```
