AgileApps Support Wiki Pre Release

Difference between revisions of "Using Logical Operators and Parentheses"

From AgileApps Support Wiki
imported>Evelyn
m
 
imported>Aeric
Line 12: Line 12:


Expressions are evaluated in this order:
Expressions are evaluated in this order:
#expressions within <tt>(parenthesis)</tt>  
#expressions within <tt>(parentheses)</tt>  
#expressions with <tt>&& (Logical AND)</tt>  
#expressions with <tt>&& (Logical AND)</tt>  
#expressions with <tt>|| (Logical OR)</tt>
#expressions with <tt>|| (Logical OR)</tt>

Revision as of 17:20, 10 June 2011

Boolean operators are used to build subexpressions within an expression, resulting in the ability to create multiple conditions and complex criteria.

<subexpression1> <Boolean_operator> <subexpression2>...

LOGICAL_OPERATOR

Logical operators can be used to build more complex expressions.
The logical operators are:
AND
OR
Considerations
  • Two subexpressions joined by a logical operator form a logical expression.
  • Logical expressions resolve to a Boolean value: 1/0 or TRUE/FALSE.
  • Use parentheses--()--to group expressions logically and to join multiple expressions.
  • Parentheses are used in pairs; each open parenthesis "(" requires a closing parenthesis ")".
  • For example:
((<expression1> AND <expression2>) OR (<expression3> AND <expression_4>))


Use parentheses (brackets) to group expressions logically and to join one or more expressions. Parentheses are used in pairs. For each left parenthesis, there must be a right parenthesis.

((<subexpression_1> && <subexpression_2>) || <subexpression_3>) && (<subexpression_4)

Precedence

Expressions are evaluated in this order:

  1. expressions within (parentheses)
  2. expressions with && (Logical AND)
  3. expressions with || (Logical OR)
If the expression is not clearly annotated with parentheses, then && (Logical AND) takes precedence over || (Logical OR)
Expression Description
(Number of Employees <50 && Area_Code = '408') || (State = 'CA' && Industry = 'Construction' This expression finds all accounts that have fewer than 50 employees located in area code 408 or accounts in the construction industry in California
(State = 'CA') || (State = 'NV') || (State = 'WA') This expression finds all accounts where the state is either California, Nevada, or Washington
(State != 'CA') && (State != 'NV') && (State != 'WA') By contrast, this expression finds all accounts where the state is not California, Nevada, or Washington
((State = 'CA') || (State = 'NV')) && (Industry = 'Construction') This expression finds all accounts in the construction industry where the state is California or Nevada
State = 'CA' || State = 'NV' && Industry = 'Construction' Taking the example from above, but removing the parentheses finds accounts in the State of California or accounts in construction in the state of Nevada
State = 'CA' || (State = 'NV' && Industry = 'Construction') Note that the AND (&&) operator implies parentheses
contains(Acct_Name, 'Equipment') && (state = 'CA' || state ='TX') This expression finds accounts in California or Texas where the account name contains "Equipment"
contains(Acct_Name, 'Equipment') && (state = 'CA') || state ='TX' This expression finds accounts in California where the account name contains "Equipment", or any record in Texas.