Iterate through rows and sum values - Using Transformation 2.0
Hi,
Could anyone give me some guidance in how to iterate through rows and create a value of all sub values.
The goal is to get a new value of TotalBoxesperPallet from BoxesperPallet values in each row.

Any guidance on the would be great.
Thanks in advance.
0
Comments
I would switch over to a JavaScript transform. I highly recommend using AI to write JavaScript code now days. You can do it in the product directly, and I promise we have a better UX coming soon, or you can do it in ChatGPT outside the product too.
Hi Scott,
Thanks for the direction, I have thrown it into ChatGPT and got exactly what I needed for the flow, after a few tweaks to the prompts.
For anyone who comes across this, and would like to know the solution I got to in the end.
Using Javascript transform…
If that is still your goal, you can totalize the BoxesperPallet with a single line of code:
There is a lot more going on in that code and I can't tell if it's just garbage chat GPT code or if your actual needs are much more complicated than your original stated desire.
I do this by creating a transformation that maps rows[*].boxesperpallet to a string array named boxesperpalletarray.
Then, you can do a {{sum boxesperpalletarray}} handlebars expression in your import mapping and you'll have the total. Easy and no code needed.
Please sign in to leave a comment.