cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Jaz
Jaz
Level IV

Nested if Statement

 

Hi,

 

I just want to make sure that the following nested if statement will function correctly. At the moment I'm getting an error so I thought it might be to do with the way I constructed my nested if statement:

If (ismissing(dt:newColumnName[k]), For Each Row(If(dt:colAutomatically <= colManually[k] & dt:colAutomatically >= colManuallyStart[k], dt:newColumnName = colInstructions[k], dt: newColumnName = colInstructions[k-1] || " & " || colInstructions[k]));

The if statement conidtion is: 

(ismissing(dt:newColumnName[k])

If this is true I want the following statement to run: 

For Each Row(If(dt:colAutomatically <= colManually[k] & dt:colAutomatically >= colManuallyStart[k], dt:newColumnName = colInstructions[k]

If this is false I want the following statement to run: 

dt: newColumnName = colInstructions[k-1] || " & " || colInstructions[k]));

 

Any help would be appreciated. 

2 REPLIES 2

Re: Nested if Statement

The expression to be evaluated if the first argument evaluated to false was inside the For Each Row() function. This code structure should do what you want:

If( Is Missing( dt:newColumnName[k] ),
	For Each Row(
		If( dt:colAutomatically <= colManually[k] & dt:colAutomatically >= colManuallyStart[k],
			dt:newColumnName = colInstructions[k]
		)
	),
	dt:newColumnName = colInstructions[k - 1] || " & " || colInstructions[k]
);
Jaz
Jaz
Level IV

Re: Nested if Statement

Hi, 

 

Thanks for your reply but I want the following statement: 

dt:newColumnName = colInstructions[k - 1] || " & " || colInstructions[k]; 

to be inside the loop. 

 

Is there any way around that? 

 

 

 

Recommended Articles