Here's a sheet worker to do that calculation - see the notes afterwards: on ( 'change:repeating_body:bodyarmorbpcur remove:repeating_body' , () => { getSectionIDs ( 'repeating_body' , idarray => { const fields = []; idarray . forEach ( id => fields . push ( `repeating_body_ ${ id } _bodyArmorBpCur` )); getAttrs ( fields , bp => { const values = Object . values ( bp ). map ( v => + v || 0 ); const sum = values . reduce (( a , b ) => a + b , 0 ); const average = Math . round ( sum / values . length ); setAttrs ({ aabpCur : average }); }); }); }); This rounds the average off to decimals. If you want to round to whole numbers, change this line: const average = Math . round (( sum / values . length ) * 100 ) / 100 ; to const average = Math . round ( sum / values . length ) ;