CumulativeSum

Description

Calculates the total value of the rows up to and including the current row in the specified column (a running total).

Syntax

CumulativeSum ( column { FOR range } )

Argument

Description

column

The column for which you want the cumulative total value of the rows up to and including the current row for group. Column can be the column name or the column number preceded by a pound sign (#). Column can also be an expression that includes a reference to the column. The datatype of column must be numeric.

FOR range (optional)

The data that will be included in the cumulative sum. For most presentation styles, values for range are:

  • ALL – (Default) The cumulative sum of all values in column.

  • GROUP n – The cumulative sum of values in column in the specified group. Specify the keyword GROUP followed by the group number: for example, GROUP 1.

  • PAGE – The cumulative sum of the values in column on a page.

For Crosstabs, specify CROSSTAB for range:

  • CROSSTAB – (Crosstabs only) The cumulative sum of all values in column in the crosstab.

For Graph and OLE objects, specify one of the following:

  • GRAPH – (Graphs only) The cumulative sum of values in column in the range specified for the Rows option.

  • OBJECT – (OLE objects only) The cumulative sum of values in column in the range specified for the Rows option.

Returns

The appropriate numeric datatype. Returns the cumulative total value of the rows.

Usage

If you specify range, CumulativeSum restarts the accumulation at the start of the range.

For graphs and OLE objects, you do not select the range when you call the function. The range has already been determined by the Rows setting on the Data property page (the Range property), and the aggregation function uses that range. Settings for Rows include the following:

In calculating the sum, null values are ignored.

Examples

Example 1

This expression returns the running total for the values that are not null in the column named salary:

CumulativeSum(salary)

Example 2

This expression returns the running total for the values that are not null in the column named salary in group 1:

CumulativeSum(salary for group 1)

Example 3

This expression entered in the Value box on the Data property page for a graph returns the running total for the salary column for the values in the graph that are not null:

CumulativeSum(salary for graph)

Example 4

This expression in a crosstab computed field returns the running total for the salary column for the values in the crosstab that are not null:

CumulativeSum(salary for crosstab)

See also