Feedback

  • Contents
 

Combining AND with OR

Best Practice: Use parentheses to group parts of any boolean expression that has multiple operators. Parentheses eliminate any doubt about the order in which the process evaluates parts of the expression. The evaluation order is inside-out. The process first evaluates anything within the innermost parentheses, then within the next parentheses out, working its way outward.

Combining AND with OR is a little more complicated, but not too much.

The Calculation Editor dialog box does not let you combine AND with OR: instead, you need to use the Custom Calculation Editor, which you access by clicking Enter a custom calculation at the bottom left corner of the Calculation Editor dialog box. Here is an example of combining AND with OR:

A

B

C

(A AND B) OR C

True

True

True

True

True

True

False

True

True

False

True

True

False

True

True

True

True

False

False

False

False

False

True

True

False

True

False

False

False

False

False

False

If you let D represent the expression (A AND B), you can see that this is basically just a more complicated version of the truth table for OR:

D

C

D OR C

True

True

True

True

False

True

False

True

True

False

False

False

Because an expression using OR is true if any of its constituent expressions is true, then the complex expression is true if and only if either (A AND B) or C is true; otherwise, it is false.

Warning: AND has precedence over OR. If an expression contains both ANDs and ORs, your process will evaluate the AND parts first, and then evaluate the OR parts. As a result, a process would evaluate X OR Y AND Z as X OR (Y AND Z) rather than (X OR Y) and Z.

Note that if you follow best practice and use parentheses to group parts of complex expressions, the precedence of AND over OR will never cause any problem or confusion.