I got stuck mapping again (sum value inside collection->array->collection->array->collection

Hello,

I still have issues with mapping nested values.

This is the output from Monday:

This is with Array aggregator:
image

I can use this formula to get the text value 222 out:
{{parseNumber(17.array[4].column_values[4].value; “,”)}}

But actually I want to sum all values from collection 4 from the collections inside the first array.

So I want to SUM:

sum(array.1.column.values.4.text;array.2.column.values.4.text;array.3.column.values.4.text;array.4.column.values.4.text … )

Until the last collection.

Is this possible?

Thanks
David

From the top of my head - I cannot experiment at the moment:

What if you apply the map function to the array you created via array aggregator? The first param would be the array, second param would be ‘column_values’.

This results in an array of arrays.

On this array you then call the flatten method to flatten the array of arrays.

On this array you call again the map method. First param the array, second param value, third param id, fourth param auto__km_

On this final array you call the sum method

Nice, thank you!

I never looked into the array functions other then map() & get() yet, very interesting solution! This opens a lot of new possibilities.

1 Like