BOFocus – Crystal Reports Tips – Tricks – Tutorials

Crystal Reports - Formulas

Creating your first formula

When creating formula’s within Crystal Reports, the Formula Editor is used.  The Formula Editor provides access to different functions and operators that can be used to create formulas. Formula fields, used in a report, are represented by the @ sign + the name of the formula.

Example: @Name

Formulas help to modify or express fields in a format different from how they are saved to the database.

Creating your first formula:

1. From the Field Explorer, right click on ‘Formula Fields’ and click New. 2. Enter the name of your new formula and click OK

There are four sections in the Formula Editor:

Report Fields (left box): Provides access to selected tables and fields

Functions (middle box): Evaluate, calculate and transform fields/data [examples: truncate (x, # places), Length (str), Trim (str), Date (YYYY, MM, DD)]

Operators (right box): Special symbols that represent an action between fields/data (examples: &, “strings”, if…then…else…, +, -, *, /, =, <, >, ) Text Box (bottom box): Formulas are written in the blank text box

Note: For this example, I’ll simply combined two fields together.  You can pick two string fields from your database and do the same

3. For this example, I’ll simply combined two string fields together.  You can pick two string fields from your database and do the same:

{Customer.Contact Last Name} & “, ” & {Customer.Contact First Name}

4. Click on the X-2 button to check for errors, if now are found, click save and close

Tagged , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

GET SOCIAL

QUICK TIP

To change the formatting for multiple text boxes at one time, hold the Shift key while clicking on each text box. Once they’ve all been selected, click on the desired formatting icon(s).

ADVERTISMENT