Crystal Reports  

Sorting Data

When you first add a database field to your report, the field's data values appear in the order in which they where originally entered into the database. By sorting records, you can organize data in a particular order to help you find and evaluate the information.

To sort your data

  1. Right-click in the Crystal Reports ActiveX Designer to access the shortcut menu.
  2. Point to Report and click Record Sort Expert to access the Record Sort Order dialog box.
  3. Highlight the field to be sorted from the Available Fields area.
  4. Click the > arrow.

    The selected field is added to the Sort Fields list.

  5. In the Sort Direction area of the dialog box, click Ascending or Descending.
  6. If sorting by more than one field, highlight the second field you want the data to be sorted by and add it to the Sort Fields list.

    Tip   The order of the fields listed in the Sort fields list is the order by which data will be sorted.

  7. Click OK when finished.

Understanding Sort Options

When you sort, the program asks you to define two things:

Sort Field

The sort field is the field that determines the order in which data appears on your report. Almost any field can be used as a sort field, including formula fields. A field's data type determines the method by which the data from that field is sorted.

Note   You cannot sort on memo or BLOB fields.
Field Type Sort Order
Single-character string fields Blanks

Punctuation

Numbers

Uppercase letters

Lowercase letters

Multiple character string field Two letters

Three letters

Four letters, etc

For example:

  • "BOB" comes before "bob"
  • "123" comes before "124"
  • " " (blank) comes before "aaa"
Currency fields Numeric order
Number fields Numeric order
Date fields Chronological order
DateTime fields Chronological order

Same-date values sorted by time

Time fields Chronological order
Boolean comparison fields False values(0)

True values (1)

Null values Null values

Non-null values

Sort Direction

The sort direction is the order in which the values are displayed, once they have been sorted.

Ascending

Ascending order means smallest to largest (1 to 9, A to Z, False to True). The program sorts the records in ascending order based on the values in the sort field you select.

Descending

Descending order means largest to smallest (9 to 1, Z to A, True to False). The program sorts the records in descending order based on the values in the sort field you select.