How to merge corresponding elements into a nested array?

Make noob here and i’m struggling in finding a way to merge two arrays into a single array with nested arrays (each is a nested two element array consisting of the values at the corresponding index from the original two arrays). My use case is I am generating a Gantt chart with date ranges and I need the date ranges formatted this way so the QuickChart api module can parse correctly. Here is what I am working with the multiple variables I have created.

Example Input Arrays:

startDates: ["06-01-2024", "07-10-2024", "08-15-2024"]
endDates: ["06-08-2024", "07-19-2024", "08-28-2024"]

Example Desired Output:

mergedDateRanges: [
    ["06-01-2024", "06-08-2024"], 
    ["07-10-2024", "07-19-2024"],
    ["08-15-2024", "08-28-2024"]
]

Here is the actual data I have on my Tools : Set Multiple Variables module after my Array Aggregator:

Actual Bundle Output:

 [
     {
         "startDates": [
             "2024-06-12T23:00:00.000Z",
             "2024-06-12T23:00:00.000Z",
             "2024-06-17T23:00:00.000Z",
             "2024-06-16T23:00:00.000Z",
             "2024-06-19T23:00:00.000Z",
             "2024-04-30T23:00:00.000Z",
             "2024-06-18T23:00:00.000Z"
         ],
         "endDates": [
             "2024-06-09T23:00:00.000Z",
             "2024-06-09T23:00:00.000Z",
             "2024-06-09T23:00:00.000Z",
             "2024-06-09T23:00:00.000Z",
             "2024-06-12T23:00:00.000Z",
             "2024-04-18T23:00:00.000Z",
             "2024-05-02T23:00:00.000Z"
         ]
     }
 ]

If I could use JS I could easily accomplish this with a for loop but I’m struggling to find a way to make this all work without using something like CustomJs (which im hoping not to use). Any insight here is hugely appreciated!

Hi @sherbethead ,

Welcome to Make Community!

We have a good solution for you. Please check the below images and notes.


This is how you have to set up your scenario.

We will give you step-by-step instructions to accomplish the need.

1 . Iterate the StartDate array Using Iterator. [ This is how you are starting a for loop in Make.com]
2. After that you have to use a Text: Aggregator as shown below. [ You can close te for loop by using this module.]


We are sharing the formula below so that you can copy and paste it into your scenario and change the value, endDate array, and Bundle Order Position.

[“{{formatDate(7.value; “MM-DD-YYYY”)}}”,“{{formatDate(get(6.endDates; 7.__IMTINDEX__); “MM-DD-YYYY”)}}”]

  1. Finally, You can create the Desired structure at the end see the below images.

Output :-

We are hoping this is what you are looking for.

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
| Book Live Implementation
Visit us here
Youtube Channel

3 Likes

This is amazing, exactly what I was looking for but couldn’t quite articulate without knowing the modules well enough yet. Thanks so much

1 Like