Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Summing columns in a row in all rows with Emacs org-mode

Tags:

emacs

org-mode

I'm using Emacs org-mode to track times worked on various tasks. The last column in the table is the weekly sum for each task:

|------+-----+-----+-----+-----+-----+-------|
| Task | Mon | Tue | Wed | Thu | Fri | Total |
|------+-----+-----+-----+-----+-----+-------|
| Foo  |   2 |   3 |   4 |   5 |   6 |    20 |
| Bar  |   2 |   3 |   4 |   5 |   7 |    21 |
#+TBLFM: @2$7=vsum($2..$6)::@3$7=vsum($2..$6)

Currently, I have to add a formula for each new row. Is there any way to customise the formula so that it calculates the sums regardless of how many rows there are?

like image 924
armandino Avatar asked May 24 '13 20:05

armandino


2 Answers

Column formula did the trick as suggested by fniessen. Here's what I ended up with:

|------+-----+-----+-----+-----+-----+-------|
| Task | Mon | Tue | Wed | Thu | Fri | Total |
|------+-----+-----+-----+-----+-----+-------|
| Foo  |   2 |   3 |   4 |   5 |   6 |    20 |
| Bar  |   2 |   3 |   4 |   5 |   7 |    21 |
#+TBLFM: $7=vsum($2..$6)

More info in the Column formulas and field formulas section from the docs.

like image 162
armandino Avatar answered Oct 16 '22 10:10

armandino


You really should take a closer look at the documentation, and read about "column formulas" (and, even, "row formulas"). A colum formula is $7=...' and is editable viaC-c ='.

like image 3
fniessen Avatar answered Oct 16 '22 10:10

fniessen