0

I'm doing some tax calculations. The tedious instructions usually read like:

  • Subtract line 7 from line 4.
  • Enter the smaller for lines 2 and 3

If I'm trying to do this in a table like below, sometimes the table lines don't exactly line up with the tax form "lines". For example:

| Line     | Amount  | Comment           |
|----------+---------+-------------------|
| L1       |    1000 | blah blah blah    |
| L2       |    1224 |                   |
| L3       |       0 |                   |
| L4       |    1224 |                   |
| L5       | :=@2+@3 | Add lines 1 and 2 |

Notice how the formula row numbers (2,3) are shifted from the named line numbers.

I saw an advanced feature where you could put labels on fields but you have to reserve a row, like this (from the info docs):

| # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
| ^ |         |     m1 |     m2 |     m3 |    mt |      |

Anyway to do a column version of that? Like this (doesn't work).

| >      | Amount          | Comment |
|--------+-----------------+---------|
| L1     |            1000 |         |
| foo    |             200 |         |
| tax    |             150 |         |
| L3     | :=@L1+@foo-@tax |         |

1 Answer 1

1

Named rows are not supported in the spreadsheet, and Org tables are really not well suited for the specific calculations that you are describing: basically manipulating a bunch of individual cells without a unifying pattern. Org tables are better for whole column operations, whole row operations and rectangular range operations, where the operation is the same on every cell.

Some alternatives are:

  • absolute references (you might want to split off the header from the table with a strategically placed newline in order to make the line numbers agree with the row numbers, do the calculations until you are happy with the result and then rejoin the header to the table by deleting that strategically placed newline):
| >      | Amount          | Comment |
|--------+-----------------+---------|

| L1     |            1000 |         |
| L2     |             200 |         |
| L3     |             150 |         |
| L4     |                 |         |
#+TBLFM: @>$2 = @1 + @2 - @3

(field formulas just get translated into #+TBLFM entries anyway, so I've done the translation already).

  • relative references (but you still have to count from where you are to where the cell is):
| >      | Amount          | Comment |
|--------+-----------------+---------|
| L1     |            1000 |         |
| foo    |             200 |         |
| tax    |             150 |         |
| L4     | :=@L1+@foo-@tax |         |
#+TBLFM: @>$2 = $-3 + $-2 - $-1

There are some other possibilities (e.g symbolic references to rows and columns - things like @< for first row and $> for last column) but they are equally (or perhaps even more) unsatisfactory in this case.

In some cases, you can simplify the formulas by reorganizing the table structure, but I don't see anything like that in this case, particularly if you want to stay close to the instructions.

You are probably better off using a real spreadsheet (or dare I suggest one of the "free" online tax services?)

I'm just the messenger, so please don't shoot me :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.