Mastering Business Analysis with Crystal Reports 9 (Wordware Applications Library)
|
To understand the concept of sorting, let's first create a new report, which you'll use throughout this chapter.
Start Crystal Reports and create a new blank report. Add the Product, Product Type, and Purchases tables. Allow the Smart Linking feature to link these tables, or refer to the ER Model diagram in Appendix A.
Once you're at the Report Design area, place the Product Name and Product Class fields (from the Product table), the Product Type Name field (from the Product Type table), and the Units in Stock and Units on Order fields (from the Purchases table) in the Details section. Resize any of the fields as necessary so that all information displays. Once you've done this, preview your report; it should look something like Figure 8-2.
Looking at this report, you'll notice that there isn't any real order to how records display. For example, look at the Product Name information on the first page of your report. You have a number of glove products, followed by some helmet products, followed by more glove products.
Finding information within this report is like looking for a needle in a haystack.
To make this report more meaningful, let's add some sorting functionality. Perform the following steps to sort the report:
-
Select Report, Record Sort Expert from the menu bar.
The Record Sort Order dialog box displays, as shown in Figure 8-3.
Figure 8-3: The Record Sort Order dialog box -
Select the Product Type Name field from the Available Fields list box.
This is the primary field that you wish your report to sort. This field is located in the Product Type table.
-
Press the Add button (>).
You'll see the Product Type Name field display in the Sort Fields list box, as shown in Figure 8-4.
Figure 8-4: Sorting your report by the Product Type Name field -
Select the Ascending option button.
This sorts records upward (in this case, alphabetically from AtoZ).
-
Press the OK button.
Figure 8-5 displays the results of your work.
Figure 8-5: A report with single sorting functionality
|