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

# sum

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

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