cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
wjalford
Level III

Can an If statement have an |

I have the statement:

If( ((col != Column( "ASSAY_PURITY" )) | col != Column( "Total Sum" )),
	If( (col[theRow] > target & !Is Missing( col[theRow] )),
		result = "Fail"
	)
);

 

 

col is a variable tracking the column name.  I am checking to see if the column name is not equal to either Assay Purity or Total Sum.  If true then it will check against a limit and it is greater than the limit than the variable result will fail.

 

Can you let me know if I can or cannot put the | or in the if statement.

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: Can an If statement have an |

The | operator is a logical OR.

 

So, in English your condition as you've written it is "if col is not ASSAY_PURITY OR col is not TOTAL SUM then..." Since col can't be both of those values at the same time that condition will always be true. You want an AND between them which is the & operator.

 

If( ((col != Column( "ASSAY_PURITY" )) & col != Column( "Total Sum" )),
	If( (col[theRow] > target & !Is Missing( col[theRow] )),
		result = "Fail"
	)
);
-Jeff

View solution in original post

2 REPLIES 2
Jeff_Perkinson
Community Manager Community Manager

Re: Can an If statement have an |

The | operator is a logical OR.

 

So, in English your condition as you've written it is "if col is not ASSAY_PURITY OR col is not TOTAL SUM then..." Since col can't be both of those values at the same time that condition will always be true. You want an AND between them which is the & operator.

 

If( ((col != Column( "ASSAY_PURITY" )) & col != Column( "Total Sum" )),
	If( (col[theRow] > target & !Is Missing( col[theRow] )),
		result = "Fail"
	)
);
-Jeff
wjalford
Level III

Re: Can an If statement have an |

Jeff,

Thank you. For some reason that logic did sit well in my head. After making the change it worked perfectly.

Regards,

Wayne