cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
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
Thierry_S
Super User

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
Thierry_S
Super User

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
Thierry_S
Super User

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
ron_horne
Super User (Alumni)

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?