11. Report-Writer Expressions and Formats : Types of Data in Expressions : Aggregates : Cumulative Aggregates
 
Share this page                  
Cumulative Aggregates
Preceding an aggregate name with the keyword cumulative or cum indicates that the cumulative value of an aggregate is to be calculated and printed. As such, you can specify cumulatives in any context (for instance, in detail sections), because you use them to provide running totals. You can apply a cumulative to any of the other aggregates. Cumulatives are particularly useful for applications that need to use running totals, such as account balance applications.
If you do not specify a breakname after the cumulative keyword, or if you specify a breakname of report, Report-Writer assumes that the cumulative aggregate refers to all data rows processed since the start of the report. If a breakname of page is specified, the cumulative aggregate refers to all data rows processed since the last page break. If a breakname is specified which is one of the break columns, the cumulative aggregate refers to all data rows processed since the last break in that column.
You can specify the preset parameter to set the cumulative function to a constant value or to the value of a column when it is initialized (that is, at the start of the break in breakname). For example, in the Account Example section of the appendix, "Report-Writer Report Examples," the aggregate, cum(acctnum) sum(amt,balance), in the detail block indicates a common use of the preset parameter. When a break occurs in acctnum, Report-Writer sets the cumulative function to the value of balance. As each new transaction is processed, Report-Writer adds the value of amt to the cumulative aggregate. Because deposits are positive and withdrawals are negative, the cumulative aggregate reflects the running balance.