Monday, October 24, 2011

Crystal Reports : The Exclusive OR

Most of you will have been comfortable using just "AND" and "OR" as boolean operators when creating crystal formulas. Once in awhile, however, we will need to use the "XOR" operator. This "exclusive" OR will only return TRUE if either of the conditions is true, yet return FALSE if both or none of the conditions is true.
Let us imagine a user database that tracks software class certifications. There are two fields, {USERS.CLASS1} AND {USERS.CLASS2}, which represent two classes any one user may have taken. To determine which users have completed just ONE (i.e. field is not null) class, but not BOTH or NONE, use the "XOR" operator thus:

ISNULL({USERS.CLASS1}) = TRUE XOR ISNULL({USERS.CLASS2}