---
schema_version: "1"
id: 7324e3d3dd1c4cb73cc99c083284d06e872f911c492776b92cfdb9094bd666d6
title: divideBy
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.6/dw-objects-functions-divideby.md
canonical_url: https://docs.mulesoft.com/dataweave/2.6/dw-objects-functions-divideby
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 70bd1e540f5c7bfbb32f0f6455896a2a06d8db2d1f02f6635d441bd020e95cd6
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
---
product: DataWeave
version: 2.6
---

# divideBy

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

## divideBy(items: Object, amount: Number): Array<Object>

Breaks up an object into sub-objects that contain the specified number of key-value pairs.

If there are fewer key-value pairs in an object than the specified number, the function will fill
the object with those pairs. If there are more pairs, the function will fill another object with the
extra pairs.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>items</code></p></td><td><p>Key-value pairs in the source object.</p></td></tr><tr><td><p><code>amount</code></p></td><td><p>The number of key-value pairs allowed in an object.</p></td></tr></tbody></table>

### Example

This example breaks up objects into sub-objects based on the specified `amount`.

#### Source

```DataWeave
%dw 2.0
import divideBy from dw::core::Objects
output application/json
---
{ "divideBy" : {"a": 1, "b" : true, "a" : 2, "b" : false, "c" : 3} divideBy 2 }
```

#### Output

```JSON
{
  "divideBy": [
    {
      "a": 1,
      "b": true
    },
    {
      "a": 2,
      "b": false
    },
    {
      "c": 3
    }
  ]
}
```
