This has been nagging me on and off for ages and I never got around to fixing it properly – how to correctly get the Org mode table formula to sum the monthly total and year-to-date total of my rainfall recordings. I’d been semi-automatically copy/pasting it for far too many years, but finally got around to reading fully how to reference rows, columns and specify ranges in the TBLFM:
Here’s the table for https://ajft.org/ajft/2022rainfall as of the end of March:
#+CAPTION: Rainfall for 2022 (Hughesdale, Vic, Australia)
| | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
| <r3> | <r5> | <r5> | <r5> | <r5> | <r5> | <r5> | <r5> | <r5> | <r5> | <r5> | <r5> | <r5> |
|------+------+------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------|
| 1 | | | | | | | | | | | | |
| 2 | | 0.5 | 1.0 | | | | | | | | | |
| 3 | | 1.0 | | | | | | | | | | |
| 4 | | | | | | | | | | | | |
| 5 | | | 52.0 | | | | | | | | | |
| 6 | 0.5 | | 4.5 | | | | | | | | | |
| 7 | 1.0 | | 0.5 | | | | | | | | | |
| 8 | 12.0 | | 1.0 | | | | | | | | | |
| 9 | 0.5 | | | | | | | | | | | |
| 10 | | | | | | | | | | | | |
| 11 | | | | | | | | | | | | |
| 12 | | | | | | | | | | | | |
| 13 | | | | | | | | | | | | |
| 14 | 0.5 | | 15.0 | | | | | | | | | |
| 15 | | | | | | | | | | | | |
| 16 | | | 4.0 | | | | | | | | | |
| 17 | | 0.5 | 0.5 | | | | | | | | | |
| 18 | | | | | | | | | | | | |
| 19 | | 1.0 | | | | | | | | | | |
| 20 | 2.0 | | | | | | | | | | | |
| 21 | | 2.0 | | | | | | | | | | |
| 22 | | | | | | | | | | | | |
| 23 | | | 1.0 | | | | | | | | | |
| 24 | | | | | | | | | | | | |
| 25 | | | | | | | | | | | | |
| 26 | | | | | | | | | | | | |
| 27 | | | | | | | | | | | | |
| 28 | | | | | | | | | | | | |
| 29 | | | | | | | | | | | | |
| 30 | 65.0 | | | | | | | | | | | |
| 31 | 0.5 | | | | | | | | | | | |
|------+------+------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------|
| Tot. | 82.0 | 5.0 | 79.5 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
|------+------+------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------|
| YtD | 82.0 | 87.0 | 166.5 | 166.5 | 166.5 | 166.5 | 166.5 | 166.5 | 166.5 | 166.5 | 166.5 | 166.5 |
#+TBLFM: @>>$2..@>>$13=vsum(@I..@II);%.1f::@>$2=@>>$2;%.1f::@>$3..@>$13=@-1+$-1;%.1f
With a table formula in three parts (separated by “::”):
@>>$2..@>>$13=vsum(@I..@II)
: Cells 2 to 13 of the second last row are a column sum of the rainfall readings for that month>$2=@>>$2
: January YtD is a special case, the year-to-date reading in cell two of the last row is equal to the monthly total, cell two of the row above@>$3..@>$13=@-1+$-1
: cells three to thirteen of the last row are the monthly total (same cell, second last row) added to the year-to-date total of the previous month
Each of the three formulae has a suffix of ;%.1f
so the value is displayed as a floating point value to one decimal placea