Next: Lookup functions, Previous: Field and range formulas, Up: The spreadsheet [Contents][Index]

When you assign a formula to a simple column reference like `$3=`

, the
same formula will be used in all fields of that column, with the following
very convenient exceptions: (i) If the table contains horizontal separator
hlines with rows above and below, everything before the first such hline is
considered part of the table *header* and will not be modified by column
formulas. Therefore a header is mandatory when you use column formulas and
want to add hlines to group rows, like for example to separate a total row at
the bottom from the summand rows above. (ii) Fields that already get a value
from a field/range formula will be left alone by column formulas. These
conditions make column formulas very easy to use.

To assign a formula to a column, type it directly into any field in the
column, preceded by an equal sign, like ‘`=$1+$2`’. When you press
`TAB` or `RET` or `C-c C-c` with the cursor still in the field,
the formula will be stored as the formula for the current column, evaluated
and the current field replaced with the result. If the field contains only
‘`=`’, the previously stored formula for this column is used. For each
column, Org will only remember the most recently used formula. In the
‘`#+TBLFM:`’ line, column formulas will look like ‘`$4=$1+$2`’. The
left-hand side of a column formula can not be the name of column, it must be
the numeric column reference or `$>`

.

Instead of typing an equation into the field, you may also use the following command:

`C-c =`(`org-table-eval-formula`

)Install a new formula for the current column and replace current field with the result of the formula. The command prompts for a formula, with default taken from the ‘

`#+TBLFM`’ line, applies it to the current field and stores it. With a numeric prefix argument(e.g.,`C-5 C-c =`) the command will apply it to that many consecutive fields in the current column.

Next: Lookup functions, Previous: Field and range formulas, Up: The spreadsheet [Contents][Index]