ander...@notam02.no wrote:

> Anyone have suggestions about how i can have a column-formula refer to
> value in previous row, but ignore the row before the first line?
> 
> Something like this:
> 
>     | 1 | 4 |   |
>     | 2 | 7 |   |
>     | 3 | 1 |   |
>     #+TBLFM: $2=random(10)::$3=(@-1$2)-$2
> 
> Evaluating this returns an error:
> 
>   "Row descriptor -1 used in line 547 leads outside table"
> 
> I tried using a lisp-expression to dispatch on the row-number, but it
> doesnt seem to consider 'if as a special-form, trying to evaluate its
> last argument anyhow.
> 
>     | 1 | 2 |   |
>     | 2 | 6 |   |
>     | 3 | 2 |   |
>     #+TBLFM: $2=random(10)::$3='(if (< @# 3) 0 (- @-1$2 $2))
> 
> but get the same error.
> 

Set the cell in the first line explicitly with a field formula (or just
a value): it overrides the column formula. Something like this:

#+TBLFM: $2=random(10)::$3=(@-1$2)-$2::@1$3 = 0

Nick


Reply via email to