cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

Can an If statement have an |

wjalford
Level III

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