There are different Boolean operators that can be used in formula in Crystal Reports. They are −
- AND
- OR
- NOT
- Eqv
- Imp
- XOR
All these operators are used to pass multiple conditions in formulas −
AND operator is used when you want both the conditions in the formula to be true. Other Boolean operators and their meaning is as mentioned in the above snapshot.
Using Boolean Operators ‘AND’ −
If {CUSTOMER.CUSTOMER_NAME} [1 to 2] = "AN" and ToText({CUSTOMER.CUSTOMER ID}) [2] = "4" then "TRUE" Else "FALSE"
Using Boolean Operators ‘AND’ and ‘OR’ −
If ({CUSTOMER.CUSTOMER_NAME} [1 to 2] = "AN" and ToText({CUSTOMER.CUSTOMER ID}) [1] = "4") or ({CUSTOMER.CUSTOMER_NAME} [1 to 2] = "Ja" and ToText({CUSTOMER.CUSTOMER ID}) [1] = "2") then "Five star rating CUSTOMER" Else "1 star rating CUSTOMER"
The if-then-Else statement is the most basic of all the control flow statements. It tells your program to execute a certain section of code only if a particular condition meets true.
If you see the following If-Then-Else statement with Boolean operators, it has allowed you to pass multiple conditions in the formula and returning the value, if the condition is true.
If({PROJECT.Customer\Customer Name} [1 to 2] = "An" and ToText({PROJECT.Time\Year}) [1] = "2") or ({Project.Customer\CUSTOMER NAME} [1 to 2] = "Ja" and ToText({PROJECT.Time\Year}) [1] = "2") Then "Five star rating CUSTOMER" Else "1 star rating CUSTOMER"
This statement says that when any of the condition is true (before and after OR operator), then it will print Five star rating customer otherwise it will print 1 star rating customer.
This formula has been saved and then added to the body of the report under the structure tab as shown in the following images −
A new column in the report has been added with the rating of the customers as mentioned in the TEST formula.
No comments:
Post a Comment