emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Difference between two rows


From: Cecil Westerhof
Subject: Re: [O] Difference between two rows
Date: Sun, 1 Jun 2014 14:24:39 +0200

2014-06-01 13:57 GMT+02:00 Michael Brand <address@hidden>:
On Sun, Jun 1, 2014 at 1:38 PM, Cecil Westerhof <address@hidden> 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(@address@hidden) == 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: @address@hidden = if("$3" == "nan", string(""), $3 - $2) ; E f-1 :: @address@hidden = if(vlen(@address@hidden) == 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]