How to create a comma separated string and strip any inputs that are empty

Hi guys,

I have an Array Aggregator which outputs multiple items where the value of an item may or may not be empty. The objective is to create a comma-separated string with only the values that exist.

For example:

Array Item 1: empty
Array Item 2: 43
Array Item 3: empty
Array Item 4: 99

Desired output:
newString: 43,99

Attached is a sample output of the Array Aggregator in case this helps.

[
    {
        "array": [
            {
                "daysToVacate": null
            },
            {
                "daysToVacate": 43
            },
            {
                "daysToVacate": null
            }
        ],
        "__IMTAGGLENGTH__": 3
    }
]

You can use the built-in function map to select the value of daysToVacate, then join and split

e.g.:

{{join(split(join(map(38.array; "daysToVacate"); ","); ","); ",")}}

(split removes empty values by default)

Screenshot_2024-05-03_110506

Output

There is only one value in your provided sample output, 43

Screenshot_2024-05-03_110542

For more information, see

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

Partner & Custom Apps

samliewrequest private consultation

Join the Make unofficial Discord server!

1 Like

Hi there, thanks for your response.

I see what you are doing, but I understand that this solution would only work if the array has a fixed number of items. My fault as I did not specify that the input array can have any number of items and any of the items may or may not be empty…

Any other ideas on how to extract only the array items that have values and then create the new string?

Nope, I did not pick single items from the array. This works on all sizes of arrays.

1 Like

You are correct (again). Thanks for your help and also the links to the tutorials

2 Likes