BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
wjalford

Not applicable

Joined:

Jan 16, 2019

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
Highlighted
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Solution

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
2 REPLIES 2
Highlighted
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Solution

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

Not applicable

Joined:

Jan 16, 2019

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