I already answered your similar question Repeat Groups Calculations can't you just use that form and remove repeat_count?
repeat_count