How to properly use Array Aggregator to map Array with multiple collections for Batch Update Rows in Google Sheets?

I have multiple collections with data that represent marketing report pulled by one of the services from their API. The structure is on the screenshot. I basically have an Array called “items” . Each item contains of multiple collections under “dimensions” and “metrics” (similar to old Google Analytics)

I want them eventually to populate rows in Google Sheet with the first row being the header row (dimension names followed by metrics names) and then there should be the values of dimensions and metrics - each row is 1 item from the source. In the source metrics collections are numbered 1,2,3 etc while dimensions are named by some names (dynamic)

Hi @Anton5, you need an iterator here, not aggregator. aand in mapped value you just put items array.

Could you elaborate more please? I want Bulk Update, not 1 by 1

Welcome to the Make community!

I think you’ll have to turn off the Map toggle and manually map each field.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Hi samilew! I tried to do it, but it resulted to only 1 row being added to Google Sheet instead of bulk update. What do I do wrong?


First you have to Iterate the 1.data.data array, before you can aggregate the values…

When you see ARRAY, think ITERATOR.

Then,

Aggregators

Every result (item/record) from iterator/list/search/match modules will output a bundle. This can result in multiple bundles, which then trigger multiple operations in future modules (one operation per bundle). To “combine” multiple bundles into a single variable, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module. The next popular aggregator is the Text Aggregator which is very flexible and can apply to many use-cases like building of JSON, CSV, HTML.

There are other types of aggregator modules, click the below links to find out more:

Array Aggregator – mapping multiple bundles into a complex field

The Array Aggregator module is very powerful because it allows you to build a complex array of collections for a later module’s field to map multiple items (collections) to it.

This is done using the “Target structure type” of an Array Aggregator module.

Here is an example:

As you can see, the “Map” toggle on complex fields are used when you have an array. You can easily build an array variable to map to a future module’s field, by using an Array Aggregator module and select the “Target Structure Type” as the future module’s field you have mapped the array into.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

It seems to work now, thank you so much!
But I still face 2 issues:

  1. the data is being appended to the sheet, not overwritten as I specify in Google Sheets module
  2. how to add header row before data rows?

@Anton5, are you using ‘update in bulk’ module or ‘add rows in bulk’ ? header row kinda goes with this, you have to input target range in sheet module. you could create an array of headers if it’s not included in input data, and merge with this data. like :

merge(split(header1,header2,header3;,);dataArray)

Regarding the module name - you were right)) I used bulk add instead of update.
As for the header row it’s not that simple. The format is really tricky for this Google Sheets module.
The Rows array (output of Array Aggregator) looks like this



it’s not a simple array. It’s array consisting of collections. Each collection is an array named values.
So I have to somehow add 1 item at the top of this array which should be a collection of 1 item, this 1 item being an array called values, something like this
{“values”:[“marker_level_1”,“marker_level_2”,“visits”,“leads”,“sales”,“profit”,“marketing_cost”,“roi”]}
The question is - how to merge this into the Rows array?

I tried a lot of things, nothing worked :frowning:

@Anton5, Add a parse json just before with input :

{“values”:[“marker_level_1”,“marker_level_2”,“visits”,“leads”,“sales”,“profit”,“marketing_cost”,“roi”]}

This will probably be a bundle (collection) consisting of array named “values”. You need to append this object to existing Array. probably add(newjson;oldarray) will work. Else might have to fiddle with toArray() toCollection() and merge() and tweak the json a little bit. ask chatgpt maybe.

Thank you brother! I finally achieved the desired result by using JSON Parser module to create header row. It consists Array included in Collection included in another Array :man_facepalming:t2:
This array I now can merge to data array in Google Sheets module

1 Like

No problem, glad I could help!

Don’t forget to bookmark this topic so you can get back to it easily in future!

I also recommend completing the Make Academy if you haven’t yet.

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 —

Getting Started

Help Centre Basics

Articles & Videos

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.