cum()

Description:

An iterative loop to get a cumulative value over records in which one of its fields has same values.

Syntax:

cum(x;Gi,…)

Note:

The function performs an iterative loop over records whose Gi field contains same values to compute expression x and add its previous value to the current one. Each time when the value of Gi field changes, perform a new round of calculation.

Parameter:

x

An expression.

Gi

Field name.

Return value:

The result of the given expression’s current value plus its previous one

Example:

 

A

 

1

=demo.query("select * from SCORES ")

 

2

=A1.derive(cum(SCORE+10;CLASS):F1)

 

Compute expression SCORE+10 on records having same CLASS field values in A1’s table sequence, get sum of the current result and the preceding result, and make the sum value of the new field F1:

3

=A1.derive(cum(SCORE+10;CLASS,STUDENTID):F1)

Compute expression SCORE+10 on records having same CLASS and STUDENTID field values in A1’s table sequence, get sum of the current result and the preceding result, and make the sum value of the new field F1: