[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Calculate differences of remote table numbers
From: |
Michael Brand |
Subject: |
Re: [O] Calculate differences of remote table numbers |
Date: |
Fri, 5 Oct 2018 19:46:47 +0200 |
Hi Karl
On Mon, Oct 1, 2018 at 5:02 PM Karl Voit <address@hidden> wrote:
> I'd like to calculate the differences between rows of numbers of a
> different table.
For this kind of shifting row or column indexes I use Calc vector
subscript. In your case:
#+NAME: my-table
| Numbers |
|---------|
| 1 |
| 5 |
| 8 |
| 12 |
| 15 |
| Line | Difference |
|------+------------|
| 1 | |
| 2 | 4 |
| 3 | 3 |
| 4 | 4 |
| 5 | 3 |
#+TBLFM: $2 = if($1 == 1, string(""), subscr(remote(my-table,
@address@hidden), @# - 1) - subscr(remote(my-table, @address@hidden), @# - 2))
or, avoiding @# completely in the formula for $2:
#+TBLFM: $2 = if($1 == 1, string(""), subscr(remote(my-table,
@address@hidden), $1) - subscr(remote(my-table, @address@hidden), $1 - 1))
See also a similar example of subscr in the subsection "Dynamic
variation of ranges" here:
https://orgmode.org/worg/org-hacks.html#field-coordinates-in-formulas
Michael