Below are two examples. The simple one requires more manual labor, but is easier to understand. The advanced one is more generic, but may be more difficult to understand.
Simple
| | 1 | 2 | 3 |
|--------+----+---+------|
| a.b | 4 | 6 | etc. |
| a | 1 | 2 | etc. |
| b | 3 | 4 | etc. |
|--------+----+---+------|
| Total: | 10 | | |
#+TBLFM: @>$2=vsum(@2$2..@2$3)::@2$2=@3$2+@4$2::@2$3=@3$3+@4$3
::
separate formulas.$x
column numberx
.@x
row numberx
.@#
current row.$#
current column.@>
last row.x..y
range betweenx
andy
wherex
andy
designate top-left and bottom-right cells to select.vsum
vector-sum, sums all elements of the given vector.
Briefly, what happens here can be described as: take values from second column third and fourth rows, add them together and save the result in the second row of the second column. Similarly, for the third column. Sum the second row between second and third columns and save the result in the last row, second column.
Advanced
| | 1 | 2 | 3 |
|--------+----+---+----|
| a.b | 4 | 6 | 11 |
| a | 1 | 2 | 5 |
| b | 3 | 4 | 6 |
|--------+----+---+----|
| Total: | 21 | | |
#+TBLFM: @>$2=vsum(@2$2..@2$4)::@2$2..@2$4=vsum(trn(pack([2, 3], @3$2..@4$4))_($#-1))
trn
transpose matrix.pack
in this particular case it will rearrange the elements of the vector into a 2-by-3 matrix.x_y
access element ofx
at coordinates given byy
.
Briefly, this extracts the rectangle between third row, second column and fourth row fourth column. Rearranges this as a 2-by-3 matrix. Transposes this matrix. Sums every row of this matrix and stores the result in the column with the index greater by one than that of the row summed. Finally, sums the second row (except for the first column) and saves that value in the second column, last row.