armandino
armandino

Reputation: 18572

Summing columns in a row in all rows with 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?

Upvotes: 11

Views: 3506

Answers (2)

armandino
armandino

Reputation: 18572

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.

Upvotes: 10

fniessen
fniessen

Reputation: 4516

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 ='.

Upvotes: 3

Related Questions