How to determine Nth occurence in a column?
Hello.
Do you know of any function or combination of functions that can achieve a new column in the data as the "occurrence" column in the screenshot below?
I would like to know if the ID in the first column is the 1st, 2nd ... Nth occurrence in that column. Is there a way to achieve this?
Thanks in advance.
Richard
Answers
-
Hi Richard
There are two similar values that you could calculate more easily
- the total number of occurrences for each ID using a Group
- the First or Last occurrence of each ID using a Lookup step
Assuming neither of those meet your needs I think it would be possible using multiple functions that utilize the Function Get cell however it would require the data to be pre-sorted (by ID in this case), would that be an issue for any subsequent operations?
0 -
Hi Josh,
Thanks for your comment. The aim is to assign a new, unique sequential ID based on the original ID, so sorting won't be an issue.
After posting the question we've been experimenting a bit with Get Cell as you suggested and what seems to work is the following:
- Sort
- Mark the first appearance of a value in a new column (with an X) and also add CurrentRow in another
- Do a lookup with this table on itself, by returning the Row number where we have the ID and the mark
- Subtract the (LookupResult-1) from the CurrentRow to get this sequential numbering
2


