Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use default org-mode spreadsheet auto-sum behavior ?

In this example:

|   | num |
|---+-----|
|   |   5 |
|   |   6 |
|   |   4 |
|---+-----|
| # |  15 |
| ^ | sum |
#+TBLFM: $sum=vsum(@2..@-1);

Every time you press "tab" in the sum area or C-c C-c in the table formula area below the table it recalculates the sum area. The problem is after it recalculates this area it adds this new sum to the current sum that's already in the area. (Try it in your emacs).

I've created this basic test to show issues I've encountered in creating complex spreadsheets in org. Until I find a solution I can't trust the sums emacs gives me because I may occasionally press C-c C-c twice and it's inconvenient to have to go and zeo out all sum values in my form every time I recalculate.

If anyone knows a solution, please let me know.

like image 273
Mauvis Ledford Avatar asked Jul 20 '11 23:07

Mauvis Ledford


2 Answers

Turns out it was a bug with the Org-mode version I was using:

release 5.23a is from Apr 23 10:17:27 2008

Kudos to Thumper_ in freenode #org-mode for pointing it out.

Be sure to update to the newest version of Org-mode, folks! :)

like image 145
Mauvis Ledford Avatar answered Oct 15 '22 19:10

Mauvis Ledford


Maybe it's more clear to use vsum(@I..@II) to indicate the rows between the 2 hlines.

I cannot reproduce your accumulation problem; and just read your answer about the bug!!

like image 25
Juancho Avatar answered Oct 15 '22 20:10

Juancho