Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
Level III

## Counting...

So I have a column like this (it is character) and I would like to create a way to add a countup of the times it occurs.  The data will be sorted by another column which is test date/time so that I can later see if the 1st or 2nd or 3rd etc...time in the Aliquot are different than the 4th or 5 etc....so how to count sequentially based on the AliquotID

AliquotID   New Column

11172            1
11172           2
11172           3
11172          4
11172         5
11172         6
11173         1
11173         2
11173         3
11173        4
11173         5
11173         6
11174         1
11174         2
11174         3
11174
11174
11174
11175
11175
11175
11175
11175
11175
11176
11176
11176
11176
11176
11176

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User

## Re: Counting...

try this formula

``````If( Lag( :AliquotID ) != :AliquotID,
x = 1,
x = x + 1
);
x;``````
Jim
4 REPLIES 4
Highlighted
Staff

## Re: Counting...

Sort by AliquotID and Date. Then run this script:

``````Current Data Table() << New Column( "Replicate", "Numeric", "Ordinal",
Formula( If( Row() == 1, 1, :AliquotID == Lag( :AliquotID ), Lag( :Replicate ), Lag( :Replicate ) + 1 )
);``````

Learn it once, use it forever!
Highlighted
Staff

## Re: Counting...

This kind of question has been asked and solved before.

Learn it once, use it forever!
Highlighted
Super User

## Re: Counting...

try this formula

``````If( Lag( :AliquotID ) != :AliquotID,
x = 1,
x = x + 1
);
x;``````
Jim
Highlighted
Level III

## Re: Counting...

Thank you so much!

Article Labels

There are no labels assigned to this post.