# Org-table running total column formula

Is it possible to write an org table colmun formula which calculates the running total of some other column? Here is a simple example of the idea: The table

``````|  1 |   |
|  2 |   |
|  5 |   |
| 10 |   |
``````

should be endowed with a column formula which gives the resulting table

``````|  1 |  1 |
|  2 |  3 |
|  5 |  8 |
| 10 | 18 |
``````

You can add from the first row to the current row thus:

``````| value | accum |
|-------+-------|
| 1     | 1     |
| 2     | 3     |
| 5     | 8     |
| 10    | 18    |
|-------+-------|
#+TBLFM: \$2=vsum(@I\$1..\$1)
``````

`@I` refers to the row after the first hline. If you don't want headings in your table, use `@1` instead.

Of course this is not super efficient for large tables since the whole sum is calculated each time. You can calculate the sum progressively as follows:

``````| value | accum |
|-------+-------|
| 1     | 1     |
| 2     | 3     |
| 5     | 8     |
| 10    | 18    |
|-------+-------|
#+TBLFM: @2\$2=\$1::\$2=\$1+@-1
``````

although I'm not sure if this second method is faster.

• The second one requires the formula to be evaluated twice, in order to converge on the correct result. – jacg Sep 6 '16 at 6:13