Crystalkeen logo; we offer Crystal reports viewers and schedulers
 
Crystalkeen header image 3
Crystalkeen header image 5

Crystal Reports Tools: Improve Performance While Saving Time and Money

  Resources  

Articles:
Administration
Advanced
Basic
Database
Financial

Tools:

Analyzers
CR Schedulers
CR UFLs
CR Viewers
DataBase Tools
Graphics
International
Mail UFLs



 
 

Add'l:
About us

Contact Us
 

CrystalReports
on Steroids

Crystal Reports: Boolean Logic

Use correct Boolean to reverse a logical AND

If you have a Boolean condition combining two clauses with AND, remember your Boolean algebra if you want to negate the statement.

Remember to change not only the operator in the individual condition but also the linking “AND” to an “OR.”

For example, selecting your high priority products is:

{@ProductType} = “Top” AND {@Sales} > 5000

The opposite, to select your low priority products is:

{@ProductType} <> “Top” OR {@Sales} <= 5000

 

Use Boolean parameters

The report has a Boolean field to indicate if the Customer was active (or not). Our user wanted the report to select Active or Inactive clients.

We used a Boolean parameter, and then to make it the question easier to answer, we created a default pick list with True and False and a description against each one. Then the selection formula was a simple

{Customer.Active} = {?Active}

 

Use IMP in your Boolean formulas to find many True values

The Imp operator returns TRUE if the two values agree, or the second value is true.

True IMP True returns True
True IMP False returns False
False IMP True returns True
False IMP False returns True

Unlike all the other Boolean operators, this is not a symmetrical operator. The order of the two Boolean values either side of the IMP does matter.

 

Boolean Simplified

Some people are intimidated by Boolean, but the truth is it's very simple. Here are the basics.

Electronic circuit designers have the good fortune to work with Boolean represented by discrete symbols representing actual physical components. So, for example, the AND operator is the AND gate.

The basic components are called gates. Draw them out on paper:

AND. Draw a big letter D. Add two inputs on the left and an output on the right:

   =D-

That approximates the Boolean AND symbol for a two-input, one-output AND. When both inputs are true, the output is true. If only one input is true, the output is false.

True or false are just different ways of saying 1 and 0 (respectively). On the electronic component, both inputs must have the logic voltage (a logic 1) for the output to have the logic voltage.

The AND can have any number of inputs. Maybe you need 21 conditions to all be true before changing the output to true. Such a scheme is common in control circuits, where you need permissives to all check OK (safety switches 1 - 10 are closed, exhaust damper is open, drain valve is closed, etc.) before you can start the system.

The OR gate is very similar. But instead of a D, you have a triangle (same orientation, flat side on the input, "arrow" end on the output). You need just one of these to be true for the output to be true.

But what if you need two of these to be true? Then put those two conditions on an AND and feed that output to the OR.

Then there's the NOT gate. It's a small o, which you can draw on the line coming into another gate if you wish. It just inverts, so a 0 becomes a 1 (whether input or output). You can use this to build NOR gates, NAND gates, and various combinations thereof. You can use it to say if X is false (NOT the input), then no permissive. Or if X is true, then no permissive (NOT the output of an OR).

So if you're confused by Boolean, just draw it out using the basic symbols and functions. It's a very useful way to build logic. And not just for electronic circuits and Crystal Reports, but for any kind of logical examination of any problem or issue.

 

This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd. It may be freely copied and distributed as long as the original copyright is displayed and no modifications are made to this material. Extracts are permitted. The names Crystal Reports and Seagate Info are trademarks owned by Business Objects.

 

  • Questions? Please write to mark@crystalkeen.com. We do want your business.
  • Do you have your own tips for Crystal Reports administrators and designers? Write to mark@crystalkeen.com and we'll post your tips with a link to your Website (or with some other attribution if you choose).
  • Crystal Reports is a subsidiary of Business Objects, which is owned by SAP.