Crystal Reports  

Fields (Basic Syntax)

Many of the fields you use when creating your report can also be referred to in your formulas. For example, database, parameter, running total, SQL expression, summary, and group name fields can all be used in a formula. You can also refer to other formula fields in your formula.

The easiest way to insert a field into your report is to double-click a field's name in the Report Fields tree. This ensures that the correct syntax for the field is used.

How Fields Appear in Formulas

Database, parameter, formula, running total and SQL expression fields have their names surrounded by braces.

Database field names are taken from the database: {Employee.Last Name}

Parameter, formula, running total, and SQL expression field names are specified when the fields are created.

Summary and group name fields look like function calls. However, they are really shorthand notation for a report field.

Example

The formula in this example uses the Xtreme database. To find out how many days it takes to ship the product from the date when the order was placed, subtract the ship date database field from the order date database field:

Rem A formula that uses database fields
formula = {Orders.Ship Date} - {Orders.Order Date}

To find the total dollar amount of a given product that was ordered, multiply its unit price by the quantity ordered:

formula = {Orders Detail.Unit Price} * _
          {Orders Detail.Quantity}
Note   The example uses the line continuation character " _ " (space underscore). See Statements.

To calculate a sale price of 80 percent of the original unit price:

formula = {Orders Detail.Unit Price} * 0.80

See Also

Basic Syntax