---
schema_version: "1"
id: df6368f79a13f11a370fd744cb11b32fb823aefc9c0f7bbaec93ae964132cce3
title: sumBy
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.3/dw-arrays-functions-sumby.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.3/dw-arrays-functions-sumby
source_site: docs.mulesoft.com
content_type: documentation
content_hash: fc21f712a4dc902b284eed1974bf06132f734be23a96d64e922860a6f4dd9193
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
# sumBy

## [](#sumby1)sumBy(Array<T>, (T) -> Number): Number

配列内の要素の値の合計を返します。

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>array</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">入力配列。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>numberSelector</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">入力配列内で数値の値を選択する DataWeave セレクター。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、いくつかの配列で要素の値の合計を計算します。両方の ​`sumBy`​ 関数コールで同じ結果が算出されています。

#### [](#ソース)ソース

```DataWeave
 %dw 2.0
 import * from dw::core::Arrays
 output application/json
 ---
{
  "sumBy" : [
    [ { a: 1 }, { a: 2 }, { a: 3 } ] sumBy $.a,
    sumBy([ { a: 1 }, { a: 2 }, { a: 3 } ], (item) -> item.a)
  ]
}
```

#### [](#出力)出力

```json
{ "sumBy" : [ 6, 6 ] }
```