Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org mode - simplify table sum formula of multiple column

Tags:

org-mode

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)
like image 787
lucky1928 Avatar asked Oct 28 '25 16:10

lucky1928


1 Answers

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.

like image 73
NickD Avatar answered Oct 31 '25 13:10

NickD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!