Dandal
Dandal

Reputation: 176

count repeats, number up each repeat instead of the total number of times it repeats

I am trying to create a formula that counts the repeated values in a column and instead of putting the number of times it is repeated, it lists those repeated:

I have tried with

=COUNTIF(CONCATENATE("Y1:Y",ROW(Y88)),Y88)

where y88 is the current row and dragging generates the set of formulas for each cell, but it doesn't work.

AND I TRIED WITH:

=COUNTIF({Y1:Y+ROW(Y88)},Y88)

But it doesn't work either.

Input

col1 col2
a   
b   
a   
b   
b   
a   

Output

col1 col2
a   1
b   1
a   2
b   2
b   3
a   3 

ANY IDEA ON HOW TO MAKE IT IN GOOGLE SHEET OR SCRIPT?

Upvotes: 1

Views: 85

Answers (1)

Harun24hr
Harun24hr

Reputation: 36890

Try COUNTIFS() with array formula.

=Arrayformula(IF(A2:A="",,COUNTIFS(A2:A, A2:A, ROW(A2:A), "<="&ROW(A2:A))))

enter image description here

Upvotes: 1

Related Questions