Incrementing ID based on column values

Hi Guys,

What I am trying to do is create a new column called ID. The ID will then increment by one each time the condition is not satisfied. The ID value will continue to increment until the end of the dataset. In the example below I am looking at the name and address columns. 

An example of what I would like the final outcome to look like is below.

 

Name                        Address                               ID

Andrew                     1 John Street                        1

Andrew                     1 John Street                        1

Laura                        2 Steve Street                       2

Laura                        2 Steve Street                       2

Mike                          3 Jane Street                         3

Nathan                      5 Smith Street                       4

 

Thanks in advance for any help that you may be able to provide.

Hi Andyg,

You can use the "Java Snippet" node; split on the space character and then conserve the first part of the created array.

Lionel

You could do a GroupBy on the address column to get all unique addresses. Then use a Maths Formulae node with Maths expression "RowIndex+1"

Now use a Joiner node between the original table and this new table with the RowIndex in it. Choose to Join by the Address Columns

You will now have a sequential number next to the addresses as you requested.

 

Simon.

2 Likes