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

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