|
Using
Primary Logical Operators in Formulae
|
|
Article
No |
Q0006 |
|
Version Applicability |
PERKS
2.45
and later |
|
Last Reviewed On |
April
27, 2000 |
SYMPTOM: The primary Logical Operators being
used to join conditions in Formulae are the Grouping Operator: () and Logical
AND, OR, NOT and indeed, EQUAL TO.
Let us consider the use of these Operators in terms of a scenario. This
is as follows.
Assume that a benefit named Child Relief is available
conditionally. To indicate if an employee is elected to receive this benefit, a Logical
field is required. Let us call it ECR (Elected for Child Relief).
It can be an Employee Other Information field.
-
For Single male or female, return value of: 1
-
For Married female and not elected for child relief, return a value of: 1
-
For Married male and elected for child relief, return value of: 1
-
Other wise, return value: 0.
RESOLUTION:
While the use of Logical AND, OR and NOT
Operator is known to most of us, it may be mentioned in this context that the default
precedence of AND Operator is higher than OR, and that of
NOT is lowest. To overcome this default precedence, we need to use Grouping
Operator.
MARRIED, FEMALE and MALE are logical variables supplied by the System
that we can use to identify the sex and marital status.
The following formula serves our purpose:
IIFN(SINGLE OR (MARRIED AND FEMALE AND NOT
ECR) OR (MARRIED AND MALE
AND ECR),1,0 )
MORE INFORMATION:
In this context, it may be mentioned
that a logical expression like <Cond1> OR <Cond2> AND <Cond3> by the
default order of precedence, is evaluated as under:
<Cond1> OR (<Cond2> AND <Cond3>)
In fact in this
case, if <Cond1> is found to be TRUE, the System would not proceed to
evaluate other conditions. This is the standard behaviour of the platform.
To alter this behaviour, and for better readability, we use the Grouping
Operator ‘()’.
Refer
to the Online Help and search for
Formula Builder for obtaining more information on the IIFN()
function.
|