How to use map() to filter with multiple keys?

Hi all!

I get data from a Google Sheet containing name-company data. It looks like this:

        "array": [
            {
                "0": "John Doe",
                "1": "John's Company"
            },
            {
                "0": "Frank Miller",
                "1": "Miller's Bikes"
            },
            {
                "0": "Tom Holland",
                "1": "Spiderman Fanshop"
            },
            ...

I have a second array, containing another set of name-company pairs, which looks the same as the other array:

        "array": [
            {
                "0": "Jane Doe",
                "1": "Jane's Company"
            },
            {
                "0": "Phillip Butler",
                "1": "Butler Shop"
            },
            {
                "0": "Frank Miller",
                "1": "Miller's Bikes"
            },
            ...

I’m iterating over the first customers array, and only want to continue with the bundles that are in BOTH arrays.

So far I’m using this filter:
{{length(map(11.array; 1; 1; 12.company.name))}} > 0

The problem:
It can happen that multiple companys share the same name, which leads to messed up results.
To avoid this, I need to filter for BOTH keys, company name and owner name.

How would I do this?

In short:
I have two arrays. I’m iterating over one and need to check if the current entry is also stored in the other array. I need to check for multiple conditions.

Solved it like this:
{{if(ifempty(12.company.name; emptystring) = get(map(11.array; 0; 1; 12.company.name); 1); true; false; )}}

That works. I don’t know how I’d solve it when comparing with 3 values, but that’s a future problem :smiley:

2 Likes

Hey there @alexb1995 :wave:

Amazing to hear that you got the ball rolling by yourself and figured out a solution!

Thank you for keeping us in the loop and sharing the solution. :pray: