How to intialize a row less than the current row in Datatable


I have a Data table with 4 columns.The condition goes like this if the current Row value <> Next Row Value i need to perform a different Rule.However,even though am resetting the current Row to the previously row for the iteration to continue.The Loop iterates to the next Row irrespective of the row been re set.Due to compliance issues i cannot attach the workflow here.Sorry for the inconvenience caused.Please find the logic below.

Eg:Current Row:4,Next Row 5
for Each Row in Datatble
If Current Row value<> Next Row Value Then
Perform some operations
set current row to last row(which is captured in a data row variable)
End If
Challenge is even after the current row has been set to last row after iteration it skips 1 row more than the expected.

Hello @amr07

better to go like this

you ill get the required row based on count you given in row index

Thanks for the reply.But i would like to know how the current row of the table can be set to the last row and also why does it increment even when the row is re set to last.