Sum of total field present into each bundle

Hello guys,

Help! I’m going crazy …
Here, I would like to count the number of fields that are present in each Bundle of my Json, to make a total sum. But it does not work :frowning: the numeric aggregator returns me 0 in output and even 0 in input!

What I want to count is, the number of variables present here, for each bundle:

How would you have done?

I attach here screenshots of my steps, but I can not attach my blueprint because I am manipulating confidential data …










I try several function in my numeric aggregator, any good result …

Thank you in advance for your help !!

Hi @Ismail

If you want to get number of collection in the result array , you can use length() function:

Best regards,

Msquare Automation
Gold Partner of Make
@Msquare_Automation

Hello @Ismail,
This is not working like that.

You’ve just directly used sum() function which accept only numeric array values like [2,5,7,8] OR you can use like this sum(value1;value2;value3;[so on]). ⇒https://www.make.com/en/help/functions/math-functions#sum--array-of-values----sum-value1-value2------

Check this first your array is not returned like I’ve mentioned above.

If you’re in Make you’ve to understand this first and think about it.
⇒ Most of the time array always has multiple collections. The collection has multiple items in key: value pairs. → https://www.make.com/en/help/tools/json#collection-vs--array

Now in your case first check that key under the collection which you need to use as a calculation. If there are multiple calculations you need to perform then use the module Set Multiple Variables. This is my created response on another post, it’s not the same but the function usage screenshot is helpful Need Help Accessing Results from All Modules Before Numeric Aggregator in Scenario - #4 by dilipborad

Your example function syntax looks like this.
sum(map(array;key))

I hope you get it.
:+1:

Hello,

Thanks for your answer.
But this solution only returns the number of collections (87 in my case) while I want to know the number of items - key:value pair - that there are in each collection (87*24 items, in my case), to then add them together to know the total number of items independently of the number of collections (2088 in my case).

Thanks for your help

Hello,

Thanks for your answer!

I think the problem in your answer is that I will have to map the name of the keys in the “set multiple variable” module. Am I wrong? However, I do not know in advance the name of the key that will be present in each collection.

Do you have any idea how to do this in this case? :roll_eyes:

Thanks again and in advance for your answer

Hi @Ismail

you can covert the collection with toArray() function and find the length of the array .

Best regards,

Msquare Automation
Gold Partner of Make
@Msquare_Automation

Thank you very much, we are moving towards the solution!

I have converted to array as you see below, I have 87 collections containing a key:value pair collection.
but when I find the length of the array, it gives me the result ‘15’ … I do not know at all where the result comes from …

Thank you for your help really! You save me

Capture d'écran 2024-10-15 081825


Capture d'écran 2024-10-15 081908
Capture d'écran 2024-10-15 081921