How to get unique items from an array of collections

How can I split an collection into two collections? Quite stuck on this one how to do it smart.
You can do a Split but maybe there is a quicker method.

I have multiple names in one row and I want to split them as I can than do a Distinct on it (otherwise it does not work, as it will see the two names as unique).

This is an example:

[
    {
        "__IMTKEY__": "Project",
        "array": [
            {
                "ACL": "Julia"
            },
            {
                "ACL": "Julia, Mike"
            },
            {
                "ACL": "Roos"
        ]
    }
]

Thank you!

Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of one module:

{{deduplicate(split(join(map(1.array; "ACL"); ","); ","))}}

Output

Screenshot_2024-07-22_220722

Give it a go and let us know if you have any issues!

For more information on these functions, please refer to the Help Center.

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 —

General

Help Center Basics

Articles & Videos

samliewrequest private consultation

Join the unofficial Make Discord server to chat with other makers!

5 Likes

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

Click to Expand Module Export Code

JSON - Copy and Paste this directly in the scenario editor

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 30,
                    "module": "util:SetVariable2",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "name": "ACL",
                        "scope": "roundtrip",
                        "value": "{{deduplicate(split(join(map(29.array; \"ACL\"); \",\"); \",\"))}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 241,
                            "y": -716
                        },
                        "restore": {
                            "expect": {
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Variable name",
                                "required": true
                            },
                            {
                                "name": "scope",
                                "type": "select",
                                "label": "Variable lifetime",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "roundtrip",
                                        "execution"
                                    ]
                                }
                            },
                            {
                                "name": "value",
                                "type": "any",
                                "label": "Variable value"
                            }
                        ],
                        "interface": [
                            {
                                "name": "ACL",
                                "label": "ACL",
                                "type": "any"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

1 Like

Great, works as a charm @samliew
Thanks a lot!

1 Like