Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
lizrdee
Level II

Recoding Columns using IF statements

Hello JMP Experts, 


I am new to IF statements and would like to use one (or something else that would accomplish the same thing) to recode a column that has a value tied to another columns value. 

 

So in the example below:

EndTime Id is a unique run ID for 8 channels. 

There are 10 repair intervals. 

I would like to assign a continuous run number (see empty column) for each unique EndTime Id, that restarts with 1 when the repair interval changes. 

 

Thank you!

 

Capture.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Thierry_S
Level VI

Re: Recoding Columns using IF statements

There is a small error in the formula: I forgot to precede one to RUN NUMBER call with ":"

If( Row() == 1,
	1,
	If( :EndTime Id != Lag( :EndTime Id, 1 ),
		Lag( :RUN NUMBER, 1 ) + 1,
		Lag( :RUN NUMBER, 1 )
	)
);
Thierry R. Sornasse

View solution in original post

3 REPLIES 3
Highlighted
Thierry_S
Level VI

Re: Recoding Columns using IF statements

Hi,

You could use the following formula (copy and paste in the Formula Editor)

	If( Row() == 1,
		1,
		If( :EndTime Id != Lag( :EndTime Id, 1 ),
			Lag( :RUN NUMBER, 1 ) + 1,
			Lag( RUN NUMBER, 1 )
		)
	);

This will only work properly if the table is sorted by EndTime Id

Thierry R. Sornasse
Highlighted
Thierry_S
Level VI

Re: Recoding Columns using IF statements

There is a small error in the formula: I forgot to precede one to RUN NUMBER call with ":"

If( Row() == 1,
	1,
	If( :EndTime Id != Lag( :EndTime Id, 1 ),
		Lag( :RUN NUMBER, 1 ) + 1,
		Lag( :RUN NUMBER, 1 )
	)
);
Thierry R. Sornasse

View solution in original post

Highlighted
ron_horne
Super User

Re: Recoding Columns using IF statements

Hi @lizrdee 

Most likely @Thierry_S 's answer is sufficient.

Otherwise, take a look at this discussion
How do I create an index column by ID? 

 

 

 

Article Labels

    There are no labels assigned to this post.