From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Voit Subject: Re: Calculate differences of remote table numbers Date: Mon, 8 Oct 2018 17:19:20 +0200 Message-ID: <2018-10-08T17-11-05@devnull.Karl-Voit.at> References: <2018-10-01T16-59-13@devnull.Karl-Voit.at> Reply-To: Karl Voit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g9XJr-0001E4-1R for emacs-orgmode@gnu.org; Mon, 08 Oct 2018 11:19:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g9XJk-0005z0-Tg for emacs-orgmode@gnu.org; Mon, 08 Oct 2018 11:19:37 -0400 Received: from [195.159.176.226] (port=48414 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g9XJk-0005vz-MG for emacs-orgmode@gnu.org; Mon, 08 Oct 2018 11:19:32 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1g9XHZ-0002xv-3p for emacs-orgmode@gnu.org; Mon, 08 Oct 2018 17:17:17 +0200 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: emacs-orgmode@gnu.org * Michael Brand wrote: > Hi Karl Hi Michael, > 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 Thanks for your post - it is working as expected! \o/ Also thanks for the URL - I added it to my knowledge base. Unfortunately, I have to admit that spreadsheets in Org are not something I can recommend to somebody who needs "something that just works" (like Excel-switcher). :-( However, when a table is finally working as expected, I really do appreciate having this table (and its derived data) within my notes and not locked away in a separate file. -- get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode: > get Memacs from https://github.com/novoid/Memacs < Personal Information Management > http://Karl-Voit.at/tags/pim/ Emacs-related > http://Karl-Voit.at/tags/emacs/