Why do you need to use get variable module to get the value?

It doesn’t make sense to me why you always has to use the get variable module:

Hi @Nicolas_Berney,

When you use 9.all_site_stock as variable name, that resolves to “0” and your variable name becomes 0.
You’re then assigning 4 different values to “0”, with the last assignment as 72.

Then, when you read 9.all_site_stock (which resolves to “0”), you’re getting back 72 since that was what was last stored.

If you wish to sum a bunch of values, there are a few ways to handle it depending on how your scenario works, but it might be easier to get them all into an array first, then use the sum() function on them.
If you have a module that outputs multiple bundles, you can use an array aggregator after to pull a specific value from each bundle and drop it into an array.

I’ve attached a blueprint you can import and run that demonstrates this.
Sum.json (5.5 KB)

In the scenario, the Iterator mimics your tools module that outputs 4 bundles.
The Array aggregator combines “Value” from each bundle into an array.
The Tools module uses the Map() function to create a simple array from the result of the Array Aggregator, then there’s a sum() function to sum them all up.

There’s a chance you can work with whatever bundle is outputting your “Variable Value” values.

1 Like

Hi Donald, ah yes, it makes much more sense to use the sum on an array of values instead. Thanks for the example, it really helps!

2 Likes