Compare 2 arrays with each other in a filter does not work

I want to process only those elements from an array whose key-value pair corresponds to a key-value pair from another array. But this doesn’t work as it should.

This is array 1, from which the containing elements are to be further processed:

[
    {
        "body": {
            "content": [
                {
                    ...
                    "title": "Test 1",
                    ...
                },
                
				...
				
                {
                    ...
                    "title": "Test 25",
                    ...
                }
            ]
        }
    }
]

This is Array 2, which specifies which elements from Array 1 are to be processed further (and only those where ‘title’ from Array 1 corresponds to the value of any ‘1’ from Array 2).

[
    {
        "array": [
            {
                "0": "1",
                "1": "Test 2"
            },
            {
                "0": "1",
                "1": "Test 4"
            },
            {
                "0": "1",
                "1": "Test 6"
            }
        ],
        "__IMTAGGLENGTH__": 3
    }
]

In this case, the elements Test 2, Test 4 and Test 9 from Array 1 should be processed further. However, the comparison does not work properly.

What have I done?

I have run an iterator over array 1 (from the LexOffice module), which splits the individual elements into bundles. The output looks like this:

[
    {
        ...
        "title": "Test 1",
		...
    },
    {
		...
        "title": "Test 2",
        ...
        },
        "version": 6,
        "__IMTINDEX__": 25,
        "__IMTLENGTH__": 25
    }
]

Previously, I generated Array 2 as described above from a Google Sheet and a subsequent ArrayAggregator.

I then activated a filter that looks like this.

And this is the wrong result:

The problem: It compares 25 times the value in the key ‘title’ of the first entry of array 1 (i.e. ‘Test 1’) with the value of ‘1’, again exclusively from the first entry of array 2. I can see this when I scroll over the variables that are compared with each other. What I would actually expect would be that it compares the ‘title’ in the first bundle with all 3 values from array 2 and passes it on accordingly or not, then the ‘title’ of bundle 2 with the 3 values from array 2 and the whole thing up to bundle 25, so that in the end 3 bundles pass the filter. What am I doing wrong?

Welcome to the Make community!

You need to use the Array Operator: Contains to check if a value is in an array.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Hello samiliew,

thank you for the welcome and for the reply.

I have adjusted it accordingly. Unfortunately, it doesn’t quite work yet. But I think I’ve made a mistake. I compared the array from the LexOffice module with array 2 from the array aggregator. But I have to compare the title values from the iterator after the LexOffice module with array 2. Now it actually compares all titles from array 1 with array 2, but I still have the problem that the title values from array 1 are only compared with the first entry from array 2 (‘Test 3’). And although title in bundle 3 matches ‘B’ from array 2, the entry does not pass the filter when I use the contains array operator.


The situation is different if I use the text equal to operator. Then bundle 3 passes the filter, but unfortunately not the other 2, because array 1 is still only compared with the first entry from array 2.

Hope you can help me out.

This is the wrong way to do it. Please see my screenshot again.

The gap here makes it not an array:

I would suggest completing the Make Academy before jumping into building a complete scenario. If you need specific assistance when you are building a scenario it’s easier to help you then. Otherwise, you can also hire a professional by posting a request in the Hire a Pro category.

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

Getting Started

Help Centre Basics

Articles & Videos

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

2 Likes

Thank you very much for the links. I’m gonna do it. Indeed I found another way to do it: I built two iterators and compared them. This worked out. But I will do the tutorials.

1 Like