From: Cecil Westerhof <cldwesterhof@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Difference between two rows
Date: Sun, 1 Jun 2014 14:24:39 +0200 [thread overview]
Message-ID: <CAG-LmmCcwrb04MCyLxQT6objgV0AyJ+gRKcGC3LvX5M820mSaA@mail.gmail.com> (raw)
In-Reply-To: <CALn3zoiRp0VEyT7Qc-CCzcvT07_UnjatK3EOrJi3kvKzN7LNBw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1594 bytes --]
2014-06-01 13:57 GMT+02:00 Michael Brand <michael.ch.brand@gmail.com>:
> On Sun, Jun 1, 2014 at 1:38 PM, Cecil Westerhof <cldwesterhof@gmail.com>
> wrote:
> > I like to calculate in a table the difference between the value in a
> field
> > in the current row and the previous field. How would I do that?
> >
> > Something like:
> > |-------+------------|
> > | value | difference |
> > |-------+------------|
> > | 12 | |
> > | 15 | 3 |
> > | 83 | 68 |
> > | 87 | 4 |
> > | 85 | -2 |
> > |-------+------------|
>
> For such cases I prefer vlen():
>
> #+TBLFM: $2 = if(vlen(@II..@0) == 1, string(""), $1 - @-1$1); E
>
Combining it with your previous help I now have (not every field will be
filled, and the table is a little different):
#+TBLFM: @-I$4..@+I$4 = if("$3" == "nan", string(""), $3 - $2) ; E f-1 ::
@-I$5..@+I$5 = if(vlen(@II..@0) == 1 || "$3" == "nan", string(""), $3 -
@-1$3); E f-1
At the moment this is good enough. But what if I would want to know the
difference between the previous filled one, divided by the distance?
For example:
|-------+------------|
| value | difference |
|-------+------------|
| 12 | |
| 15 | 3 |
| | |
| 83 | 34 |
| | |
| | |
| | |
| 87 | 1 |
| | |
| | |
| | |
| 85 | -0.5 |
| | |
|-------+------------|
--
Cecil Westerhof
[-- Attachment #2: Type: text/html, Size: 2662 bytes --]
next prev parent reply other threads:[~2014-06-01 12:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-01 11:38 Difference between two rows Cecil Westerhof
2014-06-01 11:57 ` Michael Brand
2014-06-01 12:24 ` Cecil Westerhof [this message]
2014-06-01 13:18 ` Michael Brand
2014-06-01 14:12 ` Cecil Westerhof
2014-06-01 17:57 ` Thierry Banel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAG-LmmCcwrb04MCyLxQT6objgV0AyJ+gRKcGC3LvX5M820mSaA@mail.gmail.com \
--to=cldwesterhof@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.