Compare previous fields in same repeating group

Hello everyone, I need to compare whether the value of the next field is equal to the value of the previous field in a repeating group.
ex.:
Line 1 | count 1 | value 123.00 | …
Line 2 | count 1 | value 230.00 | … (here I need to add the current value 230.00 + previous value 123.00)
Line 3 | count 2 | value 222.00 | …(here if count 2 is different from count 1 then I need to write the total amount)
Tks!