From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Re: Calculate differences of remote table numbers Date: Fri, 5 Oct 2018 19:46:47 +0200 Message-ID: References: <2018-10-01T16-59-13@devnull.Karl-Voit.at> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8UIl-00011h-GX for emacs-orgmode@gnu.org; Fri, 05 Oct 2018 13:54:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8UBq-0004Zj-SH for emacs-orgmode@gnu.org; Fri, 05 Oct 2018 13:47:03 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]:43194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8UBq-0004YJ-Km for emacs-orgmode@gnu.org; Fri, 05 Oct 2018 13:47:02 -0400 Received: by mail-lf1-x132.google.com with SMTP id p34-v6so9926006lfg.10 for ; Fri, 05 Oct 2018 10:47:02 -0700 (PDT) In-Reply-To: <2018-10-01T16-59-13@devnull.Karl-Voit.at> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Karl Voit Cc: Org Mode Hi Karl On Mon, Oct 1, 2018 at 5:02 PM Karl Voit 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, @I$1..@II$1), @# - 1) - subscr(remote(my-table, @I$1..@II$1), @# - 2)) or, avoiding @# completely in the formula for $2: #+TBLFM: $2 = if($1 == 1, string(""), subscr(remote(my-table, @I$1..@II$1), $1) - subscr(remote(my-table, @I$1..@II$1), $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