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

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