---
schema_version: "1"
id: 800dac2876e8651cf2314db8b5b64b309b411cfaa576f9128da232b0bcc7e550
title: filterArrayLeafs
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.11/dw-tree-functions-filterarrayleafs.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dw-tree-functions-filterarrayleafs
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 52bff797f6f45405f4fa77f6dbdae0a5e62cc7a3073e813277a4213af9c55bbd
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
---
product: DataWeave
version: 2.11
---

# filterArrayLeafs

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

## filterArrayLeafs(value: Any, criteria: (value: Any, path: Path) -> Boolean): Any

Applies a filtering expression to leaf or `Path` values of an array.

The leaf values in the array must be `SimpleType` or `Null` values. See
[Core Types](https://docs.mulesoft.com/dataweave/latest/dw-core-types) for descriptions of the
types.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>value</code></p></td><td><p>An input value of <code>Any</code> type.</p></td></tr><tr><td><p><code>criteria</code></p></td><td><p>Boolean expression to apply to <code>SimpleType</code> or <code>Null</code> leaf values of all arrays in the input <code>value</code>. If the result is <code>true</code>, the array retains the leaf value. If not, the function removes the leaf value from the output.</p></td></tr></tbody></table>

### Example

This example shows how `filterArrayLeafs` behaves with different inputs.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::Tree
var myArray = [1, {name: ["", true], test: 213}, "123", null]
output application/json
---
{
   a: myArray filterArrayLeafs ((value, path) ->
        !(value is Null or value is String)),
   b:  myArray filterArrayLeafs ((value, path) ->
        (value is Null or value == 1)),
   c: { a : [1,2] } filterArrayLeafs ((value, path) ->
        (value is Null or value == 1)),
   d: myArray filterArrayLeafs ((value, path) ->
        !isArrayType(path))
}
```

#### Output

```Json
{
  "a": [
    1,
    {
      "name": [
        true
      ],
      "test": 213
    }
  ],
  "b": [
    1,
    {
      "name": [

      ],
      "test": 213
    },
    null
  ],
  "c": {
    "a": [
     1
    ]
  },
  "d": [
    {
      "name": [

      ],
      "test": 213
    }
  ]
}
```
