cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
gianpaolo
Level IV

Create a sequence column

hello Community

someone can help me with JSL

i need to create a sequence column referred to another data column (as for picture example)

 

(as you can see for each wafer ID item, the data can be variable.... 5/8/4 ecc)

 

gianpaolo_0-1626359906357.png

thanks in advance

Gianpaolo

Gianpaolo Polsinelli
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Create a sequence column

Hi,

 

What you will want to use in this case is:

 

Col Cumulative Sum (1, :Wafer_ID )

If you use Col Sum ( 1, :Wafer_ID ), you will get several rows of the value "k", where k is # of rows in the given group.

 

Note that this formula works no matter how the table is sorted. Its value says "this is the k-th time I've encountered this value in this dataset, starting from the top." This has application in many other contexts, particularly when creative sorting is involved, and is one of my favorite tricks.

 

Cheers,

Brady

 

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: Create a sequence column

There are several previous discussion items that covered this......in the future, please search for known searches first

Here is one solution for the formula

col sum(1, :wafer_id);
Jim
gianpaolo
Level IV

Re: Create a sequence column

Thanks Nelson, for your answer... and sorry if didnt search deep in the other discussions

just... i miss a thing (probably my question was not well explained... sorry for that).....but i must create a column sequence by JSL... for this i need help.

 

using your suggestion:

 

dt << New Column( "Sequence", Formula( Col Sum( 1, :Wafer_ID ) ) );

 i dont optain the sequence1,2,3,... as i reported in the pic..... but i have the max of row  of wafer_ID for each wafer data.

 

what i need is to create he sequence column that contain:

wafer      Sequence

00            1

00             2

00             3

00             4

01             1

01             2

01             3

02             1

02             2

02             3

02             4

02             5

.....           ....... 

Gianpaolo Polsinelli
txnelson
Super User

Re: Create a sequence column

In your first entry, you have a column named Wafer_ID, and then in your second entry, in your JSL, you name it just wafer, but you use the name Wafer_ID in the Col Sum() function.  The Col Sum() function uses the second element as a By Group, and therefore, it must match what the name of the column you want to use for aggregation. 

Jim

Re: Create a sequence column

Here is the formula to do it. You can use it as is in a column or adapt it to your script.

 

formula.PNG

Re: Create a sequence column

Hi,

 

What you will want to use in this case is:

 

Col Cumulative Sum (1, :Wafer_ID )

If you use Col Sum ( 1, :Wafer_ID ), you will get several rows of the value "k", where k is # of rows in the given group.

 

Note that this formula works no matter how the table is sorted. Its value says "this is the k-th time I've encountered this value in this dataset, starting from the top." This has application in many other contexts, particularly when creative sorting is involved, and is one of my favorite tricks.

 

Cheers,

Brady

 

txnelson
Super User

Re: Create a sequence column

Thank you @brady_brady ........I have my grandkids at my place, and I am not focusing on the Discussion Forum as clearly as I should. 

Jim

Re: Create a sequence column

Don't focus on us at all! Have fun with the grandkids!!!

gianpaolo
Level IV

Re: Create a sequence column

Thanks to all for solved my problem. really appreciated :-)!

Gianpaolo Polsinelli