Running summation of a column<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />So I have a column in the data table and want to generate a new column with the value the summation of the first column to the current row. For example:
C1 C2
1 1
0 1
1 2
1 3
0 3
Summation(i=1,Row(),:C1 works, but it is quite wasteful and slow for long columns.
Match(Row(), 1, :C1, Lag(:C2, 1) + :C1) works well so far, even the treatment of the first row is again wasted for the other million rows.
Is there a built-in function for this? Any better ways?
Thanks,
Dong
Re: Running summation of a columntry this formula:
If( Row() == 1,
:Column 1,
Lag( :Column 2, 1 ) + :Column 1
)
In row 1, it copies the value from column 1
for all other rows, it looks at the previous value in the same column 2, and adds the value from column 1 in the current row