lucky1928
lucky1928

Reputation: 8841

org mode - simplify table sum formula of multiple column

Now I need 5 formula for sum of each column, it works fine but I wish it can be simplified to one formula. Is it possible?

|----+----+----+-----+----|
|  a |  b |  c |   d |  e |
|----+----+----+-----+----|
|  1 |  2 |  3 |   4 |  5 |
|  6 |  7 |  8 |   9 | 10 |
| 11 | 12 | 13 |  14 | 15 |
| 16 | 17 | 18 |  19 | 20 |
|----+----+----+-----+----|
| 34 | 38 | 42 | 160 | 50 |
|----+----+----+-----+----|
#+TBLFM: @>$5=vsum(@2$5..@-1$5)::@>$4=vsum(@2$1..@-1$4)::@>$3=vsum(@2$3..@-1$3)::@>$2=vsum(@2$2..@-1$2)::@>$1=vsum(@2$1..@-1$1)

Upvotes: 4

Views: 1497

Answers (1)

NickD
NickD

Reputation: 6402

This should work:

|----+----+----+----+----|
|  a |  b |  c |  d |  e |
|----+----+----+----+----|
|  1 |  2 |  3 |  4 |  5 |
|  6 |  7 |  8 |  9 | 10 |
| 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 |
|----+----+----+----+----|
| 34 | 38 | 42 | 46 | 50 |
|----+----+----+----+----|
#+TBLFM: @>$1..@>$5=vsum(@2$0..@-1$0)

$0 on the RHS is the current column.

Upvotes: 7

Related Questions