Challenge: How to accurately map & filter nested arrays? need help extracting values

Our goal is to map and filter nested arrays, extracting the median value from variationGoalData when goal: X matches the id from goals where isPrimary = true, and variation is not equal to 1.



Screenshot 2024-10-01 at 16.54.04

Make.com is missing a JavaScript to Make converter. Or a GPT that handles those conversions smoothly :slight_smile:

Welcome to Make @JorgeA;

We should attempt to break up our steps to get something working, and then later when needed, make it more efficient.

So first, I feel we should get the primary goal ids.

{{map}}(goals; id; isPrimary; {{true}})

Second, iterate through variationGoalData followed by a Text Aggregator module to create a new { "goal": 1, "data": { "variation": 2, "median": 3 } } CSV. Feed that result to Parse JSON to become the array; don’t forget to bracket wrap the [CSV].

Third iterate through the primary goal id array.

{{map}}(CSV-array; data; goal; goal-id)

Now iterate through that result, checking where variation is greater than 1 to get your desired median.

Have fun with the debugging and newly found exception cases!

1 Like