Hello, Need help to sum amount in agregator array.
There is several collections and in each collection I want to sum the amount for orderedProductSales.
Tried to set variable and with numeric aggregator but still stuck.
Thanks for your help
Welcome to the Make community!
To allow others to assist you with your request, please provide the following:
1. Output Bundles of Modules
Please provide the output bundles of 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”.
A. Upload as Text File
Save each bundle contents in your text editor as a bundle.txt
file, and upload it here into this discussion thread.
B. Insert as Formatted Code Block
If you are unable to upload files on this forum, alternatively you can paste the formatted bundles.
These are the two ways to format text so that it won’t be modified by the forum:
-
Method 1: Type code block manually
Add three backticks
```
before and after the content/bundle, like this:```
content goes here
``` -
Method 2. Highlight and click the format button in the editor
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!
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 @Carrot,
Have you tried sum() native Make function ?
see imported script :
sumArray.json (4.0 KB)
Thanks for your reply, I did but didn’t work, maybe not sure how to set up properly.
Here are the outpouts of Parse Json and Array Aggregator. If it can help.
Thank you for your help
ArrayAggregator.json (27.6 KB)
Parse.json (43.7 KB)
@Carrot, What about iteration summing ?
This is the most basic method of sum in coding. It consumes operations, though. Not very ideal.
aggregatesum.json (36.3 KB)
Thanks Kudrachaa,
I have tried yours and it s working. In mine, if I paste the json code into json string, it s working, but before parse json I got a gunzip module.
Here are the input and outpout parse json module, when I use “data” from gunzip module.
input_parse.json (29.3 KB)
ArrayAggregator.json (27.6 KB)
@Carrot I see, it’s working right?
Working if i just paste the code into JSON String, if I add the “3. Data” (as on picture above) in this field, it’s not working.
input_parse.json (29.3 KB)
This json you just gave is Gunzip output export ? If that’s the case you’ll have to parse json one more time.
The one that I sent you, is the parse json, input and output.
Now, this is the Gunzip output.
Thanks
output_gunzip.json (306 Bytes)
Thanks very much kudrachaa, your example helped me