How can I create a column with a sequence for every new id

I need to create a column that counts sequentially an ID column and re-starts the counting every time the column has a new ID. Something as shown in the image, do you know if there is a way to do that?

4df16dfa-a25f-46ec-933f-b3984c133a00.png
0 1 663
1 REPLY 1

@glorinthegalaxy  You can do this in a Table Calculation.

Where user_id is the column with the repeated value you want an incrementing number per unique value:

if(row()=match(${order_items.user_id}, ${order_items.user_id}),1,1-1*(match(${order_items.user_id}, ${order_items.user_id})-row()))

First part is `match(${order_items.user_id}, ${order_items.user_id}`. This returns the row number of the first unique occurrence of the value in the column referenced. 

Second is if the current row is equal to that, then 1, otherwise subtract the row identifier from the first part to start the sequence again.

Top Labels in this Space
Top Solution Authors