Chapter 3 - Sorting and Grouping
Being able to sort records in either ascending or descending order is a fundamental reporting skill. Sorting makes it easy for a user to quickly find a particular piece of data buried within a large report. This chapter has ten tutorials that quickly get you up to speed on every aspect of sorting and grouping data.
This is an excerpt from the book Crystal Reports Encyclopedia. Click to read more chapter excerpts.
Tutorial 3-1. Creating a grouping reportTo practice working with groups, let's modify the Employee List report created in Chapter 1. The report lists each employee on a line and we are going to modify it so that it first groups by the region and then by the city. Within this grouping it sorts by last name.
- Open the Employee List report you created in Tutorial 1-1.
- Select the menu items Report | Group Expert. This opens the Group Expert dialog box.
- In the Available Fields list click on the Employee_Addresses.Region field and drag it to the Group By list.
- Click on the Employee_Addresses.City field and drag it to the Group By list.
- Click the OK button. The dialog box closes and the two groups have been added to the report.
- In the report designer, move the report object Group #2 Name a little to the right so that it is offset from Group #1 (the Region).
- Click the OK button to save your changes. Your report's design should look similar to Figure 4-e. The report preview is in Figure 4-f.
Figure 4-5. Employee List with groupings.
Figure 4-6. Employee List preview.One unusual aspect about this report is that the first few records don't have any data in the Region field and all you see are the two cities listed (London and Nottingham). It would be nice to classify these records so that they are separate from the records that have data in the Region field. Soon we'll look at options for customizing the grouping format as well as fixing problems such as this.
To read all my books online, click here for the Crystal Reports ebooks.