The result of a formula, or the value that
is printed when the formula is placed in a report, is called the value returned
by the formula. Every formula in
Crystal Reports must return a value. For example, here is a
simple Crystal syntax formula that returns a value of 10:
10
The value returned by a formula can be one
of the seven simple data types supported. These are Number, Currency, String,
Boolean, Date, Time, and DateTime.
Note: Crystal Reports
also supports range types and array types, but these cannot be returned by a
formula.
For example, suppose a company has a
shipping policy in which orders over $1,000 are insured, but orders below that
amount are not insured:
//A formula that returns a String value
If {Orders.Order Amount} >= 1000 Then
"Insured shipping"
Else
"Regular shipping"
Tip: The text following the
two forward slashes is a comment for someone reading this formula and is
ignored by the Crystal syntax compiler.
The formula returns the text string value
"Insured shipping" if the value of the database field {Orders.Order Amount} is
greater than or equal to 1000; otherwise, it returns the text string value
"Regular Shipping" otherwise.