Split array into smaller arrays by group

My trigger produces 14 bundles. The first 13 are sales by one artist, the last is a sale by another artist.

I need to create a google sheet for each artist, and within that google sheet, I need two sections depending on the type of sale.

I was able to do the former. I use an array aggregator and I select group by Artist. My output is two bundles, one for each artist. I can then add a google sheet module which will create one spreadsheet per artist and an iterator to go through each sale and add them to the sheet, one row at a time.

Where I’m struggling is the second part. How to split each of these two Artist arrays by the type of sale. As you can see here, the output for my aggregator gives me a bundle for each artist. Within the bundle is an array of sales. Here I show the first two. The first has a sale type of Commission Deposits, the second has a sale type of Sales.

I need the Commission Deposits to start in row 6 of my spreadsheet and the Sales to start in row 20 of my spreadsheet. My plan was to split this array into 2 arrays and then use an iterator or maybe a router to go through the Commission array and put then in rows 6 through 17 (there are 12) and the Sales array in rows 20 (in this case only 20, but in the future if there are more Sales, it would be rows 20, 21, etc)

If I try another array aggregator, this time grouping by the Sale Type field, my result is still just basically the same two arrays I started with. I should end up with 3 arrays: two for my first artist which has two sale types, and one for the second artist which has one sale type

Can you share your initial output bundle json please? This will help to simulate what you’re doing.

1 Like

Download the json and share it rather than the picture. See the download output bundle button in upper right corner of your snapshot.

1 Like

[
{
“Total R Costs”: 0,
“Total Cost”: 0,
“Net Profit”: 10000,
“Due to Artist”: 0,
“R Profit”: 10000,
“Calc Consigner”: “Artist A”,
“Artist Payout Calc”: 0,
“# of Artist Prod Costs”: 0,
“ID”: “CO706a”,
“Artist”: “Artist A”,
“Retail Price”: 10000,
“Sale Price”: 10000,
“Invoice Number”: [
17922
],
“Sale Type”: [
“Sales”
],
“Invoice Date”: [
“2024-04-26”
],
“Client”: [
“Constance Caplan”
],
“Balance”: [
166800
],
“Description”: “a”,
“id”: “reccFY1OVG08saGWG”,
“createdTime”: “2024-04-29T22:16:20.000Z”,
“IMTLENGTH”: 6,
“IMTINDEX”: 1
},
{
“Total R Costs”: 0,
“Total Cost”: 0,
“Net Profit”: 20000,
“Due to Artist”: 0,
“R Profit”: 20000,
“Calc Consigner”: “Artist A”,
“Artist Payout Calc”: 0,
“# of Artist Prod Costs”: 0,
“ID”: “LC1013a”,
“Artist”: “Artist A”,
“Retail Price”: 20000,
“Sale Price”: 20000,
“QBO Item Category”: “Historical”,
“Invoice Number”: [
17922
],
“Sale Type”: [
“Sales”
],
“Invoice Date”: [
“2024-04-26”
],
“Client”: [
“Constance Caplan”
],
“Balance”: [
166800
],
“Description”: “b”,
“id”: “recuTHZ22pSznnndc”,
“createdTime”: “2024-04-29T22:16:24.000Z”,
“IMTLENGTH”: 6,
“IMTINDEX”: 2
},
{
“Total R Costs”: 0,
“Total Cost”: 0,
“Net Profit”: 30000,
“Due to Artist”: 0,
“R Profit”: 30000,
“Calc Consigner”: “Artist A”,
“Artist Payout Calc”: 0,
“# of Artist Prod Costs”: 0,
“ID”: “LC1014a”,
“Artist”: “Artist A”,
“Retail Price”: 30000,
“Sale Price”: 30000,
“QBO Item Category”: “Historical”,
“Invoice Number”: [
17038
],
“Sale Type”: [
“Commission Deposits”
],
“Invoice Date”: [
“2023-04-13”
],
“Client”: [
“Rodney Lawrence Inc.”
],
“Balance”: [
200200
],
“Description”: “c”,
“Deposit Received”: [
“2023-10-23”
],
“id”: “rec3YwEeGFpCcY5jS”,
“createdTime”: “2024-04-29T22:16:24.000Z”,
“IMTLENGTH”: 6,
“IMTINDEX”: 3
},
{
“Total R Costs”: 0,
“Total Cost”: 0,
“Net Profit”: 40000,
“Due to Artist”: 0,
“R Profit”: 40000,
“Calc Consigner”: “Artist A”,
“Artist Payout Calc”: 0,
“# of Artist Prod Costs”: 0,
“ID”: “TL485a”,
“Artist”: “Artist A”,
“Retail Price”: 40000,
“Sale Price”: 40000,
“QBO Item Category”: “Historical”,
“Invoice Number”: [
17038
],
“Sale Type”: [
“Commission Deposits”
],
“Invoice Date”: [
“2023-04-13”
],
“Client”: [
“Rodney Lawrence Inc.”
],
“Balance”: [
200200
],
“Description”: “d”,
“Deposit Received”: [
“2023-10-23”
],
“id”: “recgMe8HUhrFD7bYY”,
“createdTime”: “2024-04-29T22:16:24.000Z”,
“IMTLENGTH”: 6,
“IMTINDEX”: 4
},
{
“Total R Costs”: 0,
“Total Cost”: 0,
“Net Profit”: 50000,
“Due to Artist”: 0,
“R Profit”: 50000,
“Calc Consigner”: “Artist B”,
“Artist Payout Calc”: 0,
“# of Artist Prod Costs”: 0,
“ID”: “HL2790a”,
“Artist”: “Artist B”,
“Retail Price”: 50000,
“Sale Price”: 50000,
“QBO Item Category”: “Contemporary”,
“Invoice Number”: [
17925
],
“Sale Type”: [
“Sales”
],
“Invoice Date”: [
“2024-04-26”
],
“Client”: [
“Nicole Fuller Interiors”
],
“Balance”: [
91400
],
“Description”: “e”,
“id”: “recIjWVx3kwD7ksc5”,
“createdTime”: “2024-04-29T22:16:24.000Z”,
“IMTLENGTH”: 6,
“IMTINDEX”: 5
},
{
“Total R Costs”: 0,
“Total Cost”: 0,
“Net Profit”: 60000,
“Due to Artist”: 0,
“R Profit”: 60000,
“Calc Consigner”: “Artist B”,
“Artist Payout Calc”: 0,
“# of Artist Prod Costs”: 0,
“ID”: “CO858a”,
“Artist”: “Artist B”,
“Retail Price”: 60000,
“Sale Price”: 60000,
“QBO Item Category”: “Historical”,
“Invoice Number”: [
17038
],
“Sale Type”: [
“Commission Deposits”
],
“Invoice Date”: [
“2023-04-13”
],
“Client”: [
“Rodney Lawrence Inc.”
],
“Balance”: [
200200
],
“Description”: “f”,
“Deposit Received”: [
“2023-10-23”
],
“id”: “recJqL3n5jF8nP7Tw”,
“createdTime”: “2024-04-29T22:16:24.000Z”,
“IMTLENGTH”: 6,
“IMTINDEX”: 6
}
]

Welcome to the Make community!

I only see six (6) bundles in your above bundle output. Can you please provide the output bundle of your trigger module as well?

If you need further assistance, please provide the following:

1. Screenshots of module fields and filters

Please share screenshots of relevant module fields and filters in question? It would really help other community members to see what you’re looking at.

You can upload images here using the Upload icon in the text editor:
Screenshot_2023-10-07_111039

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

3. And most importantly, Input/Output bundles

Please provide the input and output bundles of all the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

1 Like