Progress
Language Tutorial
for Windows
Generating Reports with Control Breaks and Aggregates
In "Selecting, Sorting, and Relating Records," you learned to sort data using the BY option of the record phrase. For example, this block header in a report procedure sorts the Customer records by the Sales-rep code:
A control break separates sorted data into meaningful groups. Breaking sorted data by Sales-rep separates each sales rep’s customers into a separate break group. Break groups allow you to calculate summary data on subsets of data. For example, you could total the number of customers that each sales rep serves.
The BREAK option of the record phrase sets up your data for control breaks, as shown in this block header statement:
Once you’ve set up the control break, you can use the aggregate phrase on an output statement item to calculate summary information. The diagram below shows the syntax of the aggregate phrase.
Table 10–1 describes the aggregate options.
For example, in the code below, Sales-rep is the control break, Balance is the expression, and the aggregate phrase with the TOTAL option appears in parenthesis immediately after the expression in the DISPLAY statement:
The TOTAL aggregate option totals the balances for each break group. Each time the value of Sales-rep changes in the sorted data, Progress creates another break group, and the TOTAL BY aggregate function calculates and outputs the total of customer balances for that sales rep’s customers. Finally, at the end of the report, the TOTAL option calculates and outputs the total balances of all the break groups.
Follow these steps to demonstrate control breaks and aggregate values:
- Open
lt-10-05.p
and run it.- Choose Report. The report dialog box appears as shown in the following screen:
![]()
The members of each break group all have the same Sales-rep value. Notice that the report separates each break group with white space and outputs the result of the aggregate phrase options immediately following the break groups.
If you scroll to the bottom of the report, you can see the aggregate values for all the break groups.
- Choose OK, then Exit, and then press SPACEBAR to return to the Procedure Editor.
Here is the code for this procedure:
These notes point out the new features:
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |