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

# sum

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

## sum(@StreamCapable values: 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
```
