Aggregating freestock Values Across Multiple HTTP Responses for Unique EANs

Issue Summary: I am trying to aggregate freestock values across multiple HTTP responses for the same EAN (product code) in my Make scenario. My goal is to calculate the total freestock for each unique EAN by summing the values received in multiple HTTP responses. Currently, I am encountering difficulties in accumulating these values correctly due to the sequential nature of the HTTP responses and the limitations of the Numeric Aggregator in this context.

Current Flow (see attached image):

  1. Repeater: Repeats the process as needed.
  2. HTTP: Makes a request to retrieve records containing EAN and freestock values.
  3. JSON Parse: Parses the JSON response from the HTTP request.
  4. Iterator: Iterates over each record returned in the JSON response.
  5. Set Multiple Variables (Tools): Sets variables for EAN and freestock for each record.
  6. Numeric Aggregator (Tools): Attempts to aggregate freestock values, but the aggregation isn’t working as expected across multiple operations.

Problem Description: The Numeric Aggregator is not summing the freestock values correctly because the freestock values are received in separate HTTP responses and processed in different iterations. I want to store all freestock values for each unique EAN in an array and then calculate the total freestock for each EAN.

What I’ve tried:

  • Setting up an array to collect freestock values per EAN, but I am having trouble appending new freestock values to the existing array.
  • Using the Numeric Aggregator to sum freestock values, but it doesn’t seem to aggregate correctly across multiple operations due to the separate HTTP requests.

Desired Solution:

  1. Initialize an array (e.g., freestock_values) for each unique EAN to store all freestock values across different HTTP responses.
  2. Append each freestock value to the freestock_values array for the corresponding EAN on each HTTP response.
  3. Use the Numeric Aggregator (or another method) to calculate the sum of freestock values for each unique EAN.
  4. Output the final aggregated freestock value for each EAN so it can be updated to an Excel Google Sheet.

Questions:

  • Is there a recommended approach to dynamically append values to an array per unique EAN in Make?
  • Can you provide guidance on configuring the Numeric Aggregator or suggest an alternative solution to sum freestock values across multiple HTTP responses?

Attachment: I’ve attached an image of my current flow for reference.

Thank you for your assistance!


Welcome to the Make community!

You need to set the “Source Module” field of the aggregator to where the bundles are coming from. This is usually an Iterator module, but can also be a search/list/repeater module.

For more information, please refer to the Make Academy.

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.

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.

Did you know, this forum has a Hire a Pro category, where you can post your request for off-site specialised help on other platforms (video call/screenshare/private messaging/etc.)? This may help you get your issue resolved faster especially if it is urgent. It is important to post your request in the Hire a Pro category, as forum members are not allowed to advertise their services (even offer FREE assistance to help) in other categories like here. Once you have posted in the Hire a Pro category, that will allow other members like me to provide booking links to our calendars for a free consultation and video assistance (including screenshare)!

@samliew

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

Dear Samliew,

I’ve tried multiple methods to aggregate freestock values grouped by EAN across multiple HTTP requests, but none have achieved the desired result of summing the values by unique EAN. Here’s what I’ve attempted so far:

  • Array Aggregator: While this successfully gathers freestock values, it outputs separate bundles for each instance of the same EAN, rather than summing them.
  • Data Store: I tried using this to store and retrieve cumulative values, but encountered issues with maintaining a running total across separate requests.
  • Set Multiple Variables & Numeric Aggregator: Despite setting variables to collect freestock values and using the Numeric Aggregator to sum them, the output still shows separate entries for each EAN.

I believe the core of the issue might be that my flow is repeating, with values coming in through separate HTTP requests. Each HTTP request retrieves different freestock values for the same EAN, but because they come in as separate requests, it’s proving difficult to aggregate these values into a single summed output for each EAN.

Could you provide guidance on how best to achieve this aggregation under these conditions? Ideally, I’d like to accumulate the freestock values for each unique EAN and output a single total per EAN.

Thank you very much for your assistance!