The example Scott gave above is great, but I generally do not use reduce in helpful tips. It is a very advanced function, and the effort of learning how to use it can get in the way of doing other things. I am going to post another way to do the same thing, but if you find Scott's code easy to use, stick with that - Scott is very highly skilled in this area (more so than me!). In this code, I use the forEach functiion, which is basically a for loop, but a bit more advanced (and honestly more elegant) than a traditional for loop. You can see the basic approach is the same: in one loop, collect all the attributes to be used in getAttrs, and in a second loop inside getAttrs, perform the actual calculation. < script type = "text/worker" > </script> // custom functions to be used by sheet workers whenever needed const num = ( score , fallback = 0) => + score || fallback ; const int = ( score , fallback = 0) => parseInt( score ) || fallback ; const section_name = ( section , id , field ) => `repeating_ ${ section } _ ${ id } _ ${ field } ` ; //Melee Weapon Total weight script //Listening for changes to weapon encumberance on ( "change:repeating_meleeweapon:meleeenc change:repeating_meleeweapon:weaponcarried remove:repeating_meleeweapon" , function () { console . log ( "Weapon-enc script firing" ); getSectionIDs ( "meleeweapon" , idarray => { console . log ( idarray ); //assemble the array of attributes let fields = []; // loop through each row, and push the relevant attributes from that row to the array. idarray . forEach ( id => { fields . push ( section_name ( 'meleeweapon' , id , 'meleeenc' ), section_name ( 'meleeweapon' , id , 'weaponcarried' ) ); }); console . log ( fields ); getAttrs ( fields , values => { //An empty object to store changes in. const output = {}; //a placeholder to hold the total as it is calculated let total = 0 ; //loop through each row, and multiply properties together. idarray . forEach ( id => { const melee_enc = num ( values [ section_name ( 'meleeweapon' , id , 'meleeenc' ) ]); const weapon_carried = num ( values [ section_name ( 'meleeweapon' , id , 'weaponcarried' ) ]); total += melee_enc * weapon_carried ; }); output . totalmeleeenc = total ; console . log ( output ); //apply the changes setAttrs ( output ); }); }); }); </ script > Some variable names are different - you might find the variation helpful, it'll draw attention to the things you can change to match your own preference.