# More jsonata array filtering

**URL:** <https://discourse.nodered.org/t/more-jsonata-array-filtering/75937>\
**Category:** General\
**Tags:** jsonata\
**Created:** [1 March 2023 13:12 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937 "2023-03-01T13:12:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [1 March 2023 13:12 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/1 "2023-03-01T13:12:02Z")

</div>

I want to filter arrays for some key value with jsonata, eg:

`... `exchange-document`[`$`.kind = "A2"].`bibliographic-data`...`

but I am interested in more than one value so I have tried

`... `exchange-document`[`$`.kind = "A2" or `$`.kind = "A1"].`bibliographic-data`...`

or

`... `exchange-document`[`$`.kind = "A*"].`bibliographic-data`...`

or even

`... `exchange-document`[`$`.kind != "B2"].`bibliographic-data`...`

as well as various tries of using `$contains()`

but it doesn't seem to work. What would be the correct way of doing this? Thanks

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [1 March 2023 13:21 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/2 "2023-03-01T13:21:38Z")

</div>

Hard to help with no data. But may be the ` around the $  
p.s. Triple backticks must be on their own line and backticks not periods.

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [1 March 2023 13:30 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/3 "2023-03-01T13:30:53Z")

</div>

The ` around the $ is because $ is a key, it is not meant to be a variable.

````auto
    {
        "id": "5f676886e1f92e36",
        "type": "inject",
        "z": "d5a279b1156d9af4",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"ops:world-patent-data\":{\"$\":{\"xmlns\":\"http://www.epo.org/exchange\",\"xmlns:ops\":\"http://ops.epo.org\",\"xmlns:xlink\":\"http://www.w3.org/1999/xlink\"},\"exchange-documents\":[{\"exchange-document\":[{\"$\":{\"system\":\"ops.epo.org\",\"family-id\":\"19913584\",\"country\":\"EP\",\"doc-number\":\"1499465\",\"kind\":\"A2\"},\"bibliographic-data\":[{\"publication-reference\":[{\"document-id\":[{\"$\":{\"document-id-type\":\"docdb\"},\"country\":[\"EP\"],\"doc-number\":[\"1499465\"],\"kind\":[\"A2\"],\"date\":[\"20050126\"]},{\"$\":{\"document-id-type\":\"epodoc\"},\"doc-number\":[\"EP1499465\"],\"date\":[\"20050126\"]}]}],\"classification-ipc\":[{\"text\":[\"B23B29/02\"]}],\"classifications-ipcr\":[{\"classification-ipcr\":[{\"$\":{\"sequence\":\"1\"},\"text\":[\"B23B 29/ 02 A I \"]},{\"$\":{\"sequence\":\"2\"},\"text\":[\"F16F 7/ 00 A I \"]},{\"$\":{\"sequence\":\"3\"},\"text\":[\"F16F 7/ 108 A I \"]}]}],\"patent-classifications\":[{\"patent-classification\":[{\"$\":{\"sequence\":\"1\"},\"classification-scheme\":[{\"$\":{\"office\":\"EP\",\"scheme\":\"CPCI\"}}],\"section\":[\"B\"],\"class\":[\"23\"],\"subclass\":[\"B\"],\"main-group\":[\"29\"],\"subgroup\":[\"022\"],\"classification-value\":[\"I\"],\"generating-office\":[\"US\"]},{\"$\":{\"sequence\":\"2\"},\"classification-scheme\":[{\"$\":{\"office\":\"EP\",\"scheme\":\"CPCI\"}}],\"section\":[\"B\"],\"class\":[\"23\"],\"subclass\":[\"B\"],\"main-group\":[\"29\"],\"subgroup\":[\"022\"],\"classification-value\":[\"I\"],\"generating-office\":[\"EP\"]},{\"$\":{\"sequence\":\"3\"},\"classification-scheme\":[{\"$\":{\"office\":\"EP\",\"scheme\":\"CPCI\"}}],\"section\":[\"F\"],\"class\":[\"16\"],\"subclass\":[\"F\"],\"main-group\":[\"7\"],\"subgroup\":[\"108\"],\"classification-value\":[\"I\"],\"generating-office\":[\"US\"]},{\"$\":{\"sequence\":\"4\"},\"classification-scheme\":[{\"$\":{\"office\":\"EP\",\"scheme\":\"CPCI\"}}],\"section\":[\"F\"],\"class\":[\"16\"],\"subclass\":[\"F\"],\"main-group\":[\"7\"],\"subgroup\":[\"108\"],\"classification-value\":[\"I\"],\"generating-office\":[\"EP\"]}]}],\"application-reference\":[{\"$\":{\"doc-id\":\"16057428\"},\"document-id\":[{\"$\":{\"document-id-type\":\"docdb\"},\"country\":[\"EP\"],\"doc-number\":[\"03747542\"],\"kind\":[\"A\"]},{\"$\":{\"document-id-type\":\"epodoc\"},\"doc-number\":[\"EP20030747542\"],\"date\":[\"20030414\"]},{\"$\":{\"document-id-type\":\"original\"},\"doc-number\":[\"03747542\"]}]}],\"priority-claims\":[{\"priority-claim\":[{\"$\":{\"sequence\":\"1\",\"kind\":\"national\"},\"document-id\":[{\"$\":{\"document-id-type\":\"epodoc\"},\"doc-number\":[\"NO20020002077\"],\"date\":[\"20020430\"]},{\"$\":{\"document-id-type\":\"original\"},\"doc-number\":[\"20022077\"]}]},{\"$\":{\"sequence\":\"2\",\"kind\":\"national\"},\"document-id\":[{\"$\":{\"document-id-type\":\"epodoc\"},\"doc-number\":[\"WO2003NO00124\"],\"date\":[\"20030414\"]},{\"$\":{\"document-id-type\":\"original\"},\"doc-number\":[\"NO2003000124\"]}]}]}],\"parties\":[{\"applicants\":[{\"applicant\":[{\"$\":{\"sequence\":\"1\",\"data-format\":\"epodoc\"},\"applicant-name\":[{\"name\":[\"TEENESS ASA [NO]\"]}]},{\"$\":{\"sequence\":\"1\",\"data-format\":\"original\"},\"applicant-name\":[{\"name\":[\"TEENESS ASA\"]}]}]}],\"inventors\":[{\"inventor\":[{\"$\":{\"sequence\":\"1\",\"data-format\":\"epodoc\"},\"inventor-name\":[{\"name\":[\"DIGERNES ANDERS [NO]\"]}]},{\"$\":{\"sequence\":\"1\",\"data-format\":\"original\"},\"inventor-name\":[{\"name\":[\"DIGERNES, ANDERS\"]}]}]}]}],\"invention-title\":[{\"_\":\"DÄMPFUNGSVORRICHTUNG ZUR DÄMPFUNG VON SCHWINGUNGEN\",\"$\":{\"lang\":\"de\"}},{\"_\":\"APPAREIL AMORTISSEUR POUR AMORTIR DES VIBRATIONS\",\"$\":{\"lang\":\"fr\"}},{\"_\":\"DAMPING APPARATUS FOR THE DAMPING OF VIBRATIONS\",\"$\":{\"lang\":\"en\"}}]}]},{\"$\":{\"system\":\"ops.epo.org\",\"family-id\":\"19913584\",\"country\":\"EP\",\"doc-number\":\"1499465\",\"kind\":\"B1\"},\"bibliographic-data\":[{\"publication-reference\":[{\"document-id\":[{\"$\":{\"document-id-type\":\"docdb\"},\"country\":[\"EP\"],\"doc-number\":[\"1499465\"],\"kind\":[\"B1\"],\"date\":[\"20060830\"]},{\"$\":{\"document-id-type\":\"epodoc\"},\"doc-number\":[\"EP1499465\"],\"date\":[\"20060830\"]}]}],\"classifications-ipcr\":[{\"classification-ipcr\":[{\"$\":{\"sequence\":\"1\"},\"text\":[\"B23B 29/ 02 A I \"]},{\"$\":{\"sequence\":\"2\"},\"text\":[\"F16F 7/ 00 A I \"]},{\"$\":{\"sequence\":\"3\"},\"text\":[\"F16F 7/ 108 A I \"]}]}],\"patent-classifications\":[{\"patent-classification\":[{\"$\":{\"sequence\":\"1\"},\"classification-scheme\":[{\"$\":{\"office\":\"EP\",\"scheme\":\"CPCI\"}}],\"section\":[\"B\"],\"class\":[\"23\"],\"subclass\":[\"B\"],\"main-group\":[\"29\"],\"subgroup\":[\"022\"],\"classification-value\":[\"I\"],\"generating-office\":[\"US\"]},{\"$\":{\"sequence\":\"2\"},\"classification-scheme\":[{\"$\":{\"office\":\"EP\",\"scheme\":\"CPCI\"}}],\"section\":[\"B\"],\"class\":[\"23\"],\"subclass\":[\"B\"],\"main-group\":[\"29\"],\"subgroup\":[\"022\"],\"classification-value\":[\"I\"],\"generating-office\":[\"EP\"]},{\"$\":{\"sequence\":\"3\"},\"classification-scheme\":[{\"$\":{\"office\":\"EP\",\"scheme\":\"CPCI\"}}],\"section\":[\"F\"],\"class\":[\"16\"],\"subclass\":[\"F\"],\"main-group\":[\"7\"],\"subgroup\":[\"108\"],\"classification-value\":[\"I\"],\"generating-office\":[\"US\"]},{\"$\":{\"sequence\":\"4\"},\"classification-scheme\":[{\"$\":{\"office\":\"EP\",\"scheme\":\"CPCI\"}}],\"section\":[\"F\"],\"class\":[\"16\"],\"subclass\":[\"F\"],\"main-group\":[\"7\"],\"subgroup\":[\"108\"],\"classification-value\":[\"I\"],\"generating-office\":[\"EP\"]}]}],\"application-reference\":[{\"$\":{\"doc-id\":\"16057428\"},\"document-id\":[{\"$\":{\"document-id-type\":\"docdb\"},\"country\":[\"EP\"],\"doc-number\":[\"03747542\"],\"kind\":[\"A\"]},{\"$\":{\"document-id-type\":\"epodoc\"},\"doc-number\":[\"EP20030747542\"],\"date\":[\"20030414\"]},{\"$\":{\"document-id-type\":\"original\"},\"doc-number\":[\"03747542\"]}]}],\"priority-claims\":[{\"priority-claim\":[{\"$\":{\"sequence\":\"1\",\"kind\":\"national\"},\"document-id\":[{\"$\":{\"document-id-type\":\"epodoc\"},\"doc-number\":[\"NO20020002077\"],\"date\":[\"20020430\"]},{\"$\":{\"document-id-type\":\"original\"},\"doc-number\":[\"20022077\"]}]},{\"$\":{\"sequence\":\"2\",\"kind\":\"national\"},\"document-id\":[{\"$\":{\"document-id-type\":\"epodoc\"},\"doc-number\":[\"WO2003NO00124\"],\"date\":[\"20030414\"]},{\"$\":{\"document-id-type\":\"original\"},\"doc-number\":[\"NO2003000124\"]}]}]}],\"parties\":[{\"applicants\":[{\"applicant\":[{\"$\":{\"sequence\":\"1\",\"data-format\":\"epodoc\"},\"applicant-name\":[{\"name\":[\"TEENESS ASA [NO]\"]}]},{\"$\":{\"sequence\":\"1\",\"data-format\":\"original\"},\"applicant-name\":[{\"name\":[\"TEENESS ASA\"]}]}]}],\"inventors\":[{\"inventor\":[{\"$\":{\"sequence\":\"1\",\"data-format\":\"epodoc\"},\"inventor-name\":[{\"name\":[\"DIGERNES ANDERS [NO]\"]}]},{\"$\":{\"sequence\":\"1\",\"data-format\":\"original\"},\"inventor-name\":[{\"name\":[\"DIGERNES, ANDERS\"]}]}]}]}],\"invention-title\":[{\"_\":\"DÄMPFUNGSVORRICHTUNG ZUR DÄMPFUNG VON SCHWINGUNGEN\",\"$\":{\"lang\":\"de\"}},{\"_\":\"APPAREIL AMORTISSEUR POUR AMORTIR DES VIBRATIONS\",\"$\":{\"lang\":\"fr\"}},{\"_\":\"DAMPING APPARATUS FOR THE DAMPING OF VIBRATIONS\",\"$\":{\"lang\":\"en\"}}]}]}]}]}}",
        "payloadType": "json",
        "x": 370,
        "y": 440,
        "wires": [
            [
                "4f80779aeb75f948"
            ]
        ]
    },
    {
        "id": "4f80779aeb75f948",
        "type": "change",
        "z": "d5a279b1156d9af4",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload.test",
                "pt": "msg",
                "to": "$zip(**.`exchange-document`[`$`.kind = \"B\"].`bibliographic-data`.`publication-reference`.`document-id`[`$`.`document-id-type`=\"docdb\"].\t$join([**.country, **.`doc-number`]),**.`exchange-document`.`bibliographic-data`.`publication-reference`.\t`document-id`.$zip(country,`doc-number`,kind, date),**.`family-id`)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 640,
        "y": 460,
        "wires": [
            [
                "461be6079dc1ad01"
            ]
        ]
    },
    {
        "id": "461be6079dc1ad01",
        "type": "debug",
        "z": "d5a279b1156d9af4",
        "name": "debug 86",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 440,
        "wires": []
    }
] ```
````

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [1 March 2023 14:18 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/4 "2023-03-01T14:18:48Z")

</div>

try

```auto
**.'exchange-document'['$'.kind = "B1"].'bibliographic-data'[0].
`publication-reference`[0].`document-id`[`$`.`document-id-type`= "docdb"].
$join([country, `doc-number`])[]	

```

p.s. that is one messed up object

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [1 March 2023 14:33 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/5 "2023-03-01T14:33:00Z")

</div>

Thanks. I have managed to filter by one value, e.g. B1, but as they can be A1, A2, B1, B2, B8, etc I would like to filter by either a wildcard, e.g. B\*, or an or statement, e.g. B1 or B2.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [1 March 2023 14:35 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/6 "2023-03-01T14:35:13Z")

</div>

```auto
[$substring(`$`.kind, 0,1) ="B"]

```

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [1 March 2023 14:41 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/7 "2023-03-01T14:41:31Z")

</div>

Perfect, thanks

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [2 March 2023 12:21 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/8 "2023-03-02T12:21:41Z")

</div>

As my new question would get the same heading, I will not create a new post.

Perhaps @E1cid can help me out again.

In an array of arrays, if the value in the [z][y][0] position is "EP", I would like the query to give me the value in the [z][y][1] position.

So in the below sample flow, which is the closest I've got to a solution, payload[0][0][0] is "EP" so I would like the query to give me the value of payload[0][0][1], i.e. 3812066.

```auto
[
    {
        "id": "f97084c3a7ab684e",
        "type": "inject",
        "z": "d5a279b1156d9af4",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[[[\"EP\",\"3812066\",\"A1\",\"20210428\"],\"68342579\"],[[\"CN\",\"114555268\",\"A\",\"20220527\"],\"68342579\"],[[\"WO\",\"2021078416\",\"A1\",\"20210429\"],\"68342579\"]]",
        "payloadType": "json",
        "x": 950,
        "y": 860,
        "wires": [
            [
                "936f0cf620f5c86a"
            ]
        ]
    },
    {
        "id": "936f0cf620f5c86a",
        "type": "change",
        "z": "d5a279b1156d9af4",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$[0][$[0] =\"EP\"].$[1]\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1100,
        "y": 860,
        "wires": [
            [
                "77821c9716abc85a"
            ]
        ]
    },
    {
        "id": "77821c9716abc85a",
        "type": "debug",
        "z": "d5a279b1156d9af4",
        "name": "debug 87",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1260,
        "y": 860,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 March 2023 14:40 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/9 "2023-03-02T14:40:50Z")

</div>

Sorry not understanding  
please show what output you would like from the input payload supplied

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [2 March 2023 14:59 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/10 "2023-03-02T14:59:38Z")

</div>

So, in the array of arrays I want to search for a value in position [0] in the deepest array and if I find it I want to output the value in position [1] in the same array. An example would be to search for "EP" in the first position in three arrays in payload[0]. As you can see, the array in payload[0][0] has "EP" in the [0] position, so my query should output the value in the [1] position in the same array, i.e. payload[0][0][1] = "3812006"

```auto
[
    [
        [
            "EP",
            "3812066",
            "A1",
            "20210428"
        ],
        "68342579"
    ],
    [
        [
            "CN",
            "114555268",
            "A",
            "20220527"
        ],
        "68342579"
    ],
    [
        [
            "WO",
            "2021078416",
            "A1",
            "20210429"
        ],
        "68342579"
    ]
]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 March 2023 15:10 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/11 "2023-03-02T15:10:11Z")

</div>

I will ask again, please supply what the output should look like for the input array supplied.  
It will make things totally clear to me.

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [2 March 2023 15:14 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/12 "2023-03-02T15:14:54Z")

</div>

"3812006"

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 March 2023 15:18 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/13 "2023-03-02T15:18:05Z")

</div>

> [@tobiasselin](#):
>
> ```auto
> [
> [
> [
> "EP",
> "3812066",
> "A1",
> "20210428"
> ],
> "68342579"
> ],
> [
> [
> "CN",
> "114555268",
> "A",
> "20220527"
> ],
> "68342579"
> ],
> [
> [
> "WO",
> "2021078416",
> "A1",
> "20210429"
> ],
> "68342579"
> ]
> ]
> 
> ```

so form the above array you want the output to be

> [@tobiasselin](#):
>
> "3812006"

if ep at position 0 in first element, what about other elements?  
If incorrect please supply what the whole output should be from input array supplied.

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [2 March 2023 15:24 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/14 "2023-03-02T15:24:46Z")

</div>

Yes, that is correct. The output should be "3821066" if "EP" or "114555268" if "CN" is found, etc.

It would also be interesting to know how the output becomes "68342579" if "EP" is found (although this value is the same in all arrays, but as an example).

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 March 2023 15:28 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/15 "2023-03-02T15:28:04Z")

</div>

I give up, How hard is it to give an example of what the output should be. Same as you gave an example of input.

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [2 March 2023 16:06 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/16 "2023-03-02T16:06:46Z")

</div>

If “3821066“ is not an example of a wanted output then I don’t know what you mean by output.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2023 16:20 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/17 "2023-03-02T16:20:09Z")

</div>

> [@tobiasselin](#):
>
> The issue is that they are on the same level in the array and I don’t know how to solve that with jsonata.

In that case do it with javascript. It will be a bit more efficient anyway.  
As you can see, we have failed to fully grasp your description of the problem.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2023 16:21 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/18 "2023-03-02T16:21:37Z")

</div>

Perhaps you just mean that you want `msg.payload[0][0][1]`

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [2 March 2023 16:25 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/19 "2023-03-02T16:25:09Z")

</div>

It was another example to make it more clear, obviously failed.

---

<div class="post-metadata">

**Author:** ![tobiasselin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasselin/32/4492_2.png) [@tobiasselin](https://discourse.nodered.org/u/tobiasselin)\
**Post date:** [2 March 2023 16:35 UTC](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937/20 "2023-03-02T16:35:02Z")

</div>

That would indeed give me that output, but then I need to know where the value is.

I’m interested in arrays containing “EP” in a given position, and if I find it I want to output a value from another position in the same array.

I search for a value out of a small set of two-character strings (i.e. easy to find) and thereby get the value I’m after (impossible to find directly as it is basically random).

The issue is that they are on the same level in the array and I don’t know how to solve that with jsonata.

[Next page](https://discourse.nodered.org/t/more-jsonata-array-filtering/75937.md?page=2)
