Crystal Reports  

Fields (Crystal 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, you can just subtract the ship date database field from the order date database field:

//A formula that uses database fields
{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:

{Orders Detail.Unit Price} * {Orders Detail.Quantity}

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

{Orders Detail.Unit Price} * 0.80

See Also

Crystal Syntax