Home > Enterprise >  Auto increment by condition in Google Sheet
Auto increment by condition in Google Sheet

Time:10-30

I have 2 columns with ID1 AND ID2:

ID1 ID2
1 1
1 2
2 1
2 2
2 3
3 1
3 2

I want to get an auto-increment formula for ID2 - when ID1 changes, the ID2 should start from the beginning.

CodePudding user response:

For a solution using arrayformula, you could try in B2

=Arrayformula(if(A2:A="",,countifs(A2:A, A2:A, row(A2:A), "<="&row(A2:A))))

CodePudding user response:

Try below COUNTIFS() formula.

=COUNTIFS($A$2:$A2,A2)

enter image description here

  • Related