emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Recursive formulaes in org-mode tables
@ 2015-10-13 15:35 michael.zombok
  2015-10-13 17:17 ` Shankar Rao
  2015-10-14  6:42 ` Eric S Fraga
  0 siblings, 2 replies; 4+ messages in thread
From: michael.zombok @ 2015-10-13 15:35 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I have the following table:

| Year (Beginn) |    Price | Increase |
|---------------+----------+----------|
|          2016 | 20000.00 |  1000.00 |
|          2017 |          |  1000.00 |
|          2018 |          |  1000.00 |
|          2019 |          |  1000.00 |
|          2020 |          |  1000.00 |
|          2021 |          |  1000.00 |
|          2022 |          |  1000.00 |
|          2023 |          |  1000.00 |
|          2024 |          |  1000.00 |
|          2025 |          |  1000.00 |
|          2026 |          |  1000.00 |
|          2027 |          |  1000.00 |
|          2028 |          |  1000.00 |
|          2029 |          |  1000.00 |
|          2030 |          |  1000.00 |
|---------------+----------+----------|

I want to compute the price recursively such that the final table looks
like this:

| Year (Beginn) |    Price | Increase |
|---------------+----------+----------|
|          2016 | 20000.00 |  1000.00 |
|          2017 | 22000.00 |  1000.00 |
|          2018 | 24000.00 |  1000.00 |
|          2019 | 26000.00 |  1000.00 |
|          2020 | 28000.00 |  1000.00 |
|          2021 | 30000.00 |  1000.00 |
|          2022 | 32000.00 |  1000.00 |
|          2023 | 34000.00 |  1000.00 |
|          2024 | 36000.00 |  1000.00 |
|          2025 | 38000.00 |  1000.00 |
|          2026 | 40000.00 |  1000.00 |
|          2027 | 42000.00 |  1000.00 |
|          2028 | 44000.00 |  1000.00 |
|          2029 | 46000.00 |  1000.00 |
|          2030 | 48000.00 |  1000.00 |
|---------------+----------+----------|
After reading a related SO question I tried the formula

#+TBLFM: @<<<..>$2=@<<..>>$2+2*$3

but it doesn't work. It gives an error and also seems to operate on
column one instead of the specified column two. Any idea how to
correctly compute column two? I am using org-mode version 8.2.5c with
Emacs version 24.5.1.

Disclaimer: I posted this question also on Stack Overflow:

http://stackoverflow.com/questions/33063425/recursive-formulaes-in-org-mode-tables

Feel free to answer here or there.

Thanks!

Best,
Michael

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Recursive formulaes in org-mode tables
  2015-10-13 15:35 Recursive formulaes in org-mode tables michael.zombok
@ 2015-10-13 17:17 ` Shankar Rao
  2015-10-14  6:42 ` Eric S Fraga
  1 sibling, 0 replies; 4+ messages in thread
From: Shankar Rao @ 2015-10-13 17:17 UTC (permalink / raw)
  To: michael.zombok; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3371 bytes --]

I posted the following on Stack Overflow:

I recommend using the following range formula:

| Year (Beginn) |    Price | Increase |
|---------------+----------+----------|
|          2016 | 20000.00 |  1000.00 |
|          2017 |          |  1000.00 |
|          2018 |          |  1000.00 |
|          2019 |          |  1000.00 |
|          2020 |          |  1000.00 |
|          2021 |          |  1000.00 |
|          2022 |          |  1000.00 |
|          2023 |          |  1000.00 |
|          2024 |          |  1000.00 |
|          2025 |          |  1000.00 |
|          2026 |          |  1000.00 |
|          2027 |          |  1000.00 |
|          2028 |          |  1000.00 |
|          2029 |          |  1000.00 |
|          2030 |          |  1000.00 |
|---------------+----------+----------|
#+TBLFM: @<<<$2..@>$2=@<<$0+2*vsum(@<<$3..@-1$3);%.2f

You could write a recursive formula, but that would propagate one row at a
time. Even org-table-iterate (C-u C-u C-c * on any table cell) would have
to be called more than once, since it stops after 10 iterations.

Shankar Rao



On Tue, Oct 13, 2015 at 8:35 AM, <michael.zombok@googlemail.com> wrote:

> Hi,
>
> I have the following table:
>
> | Year (Beginn) |    Price | Increase |
> |---------------+----------+----------|
> |          2016 | 20000.00 |  1000.00 |
> |          2017 |          |  1000.00 |
> |          2018 |          |  1000.00 |
> |          2019 |          |  1000.00 |
> |          2020 |          |  1000.00 |
> |          2021 |          |  1000.00 |
> |          2022 |          |  1000.00 |
> |          2023 |          |  1000.00 |
> |          2024 |          |  1000.00 |
> |          2025 |          |  1000.00 |
> |          2026 |          |  1000.00 |
> |          2027 |          |  1000.00 |
> |          2028 |          |  1000.00 |
> |          2029 |          |  1000.00 |
> |          2030 |          |  1000.00 |
> |---------------+----------+----------|
>
> I want to compute the price recursively such that the final table looks
> like this:
>
> | Year (Beginn) |    Price | Increase |
> |---------------+----------+----------|
> |          2016 | 20000.00 |  1000.00 |
> |          2017 | 22000.00 |  1000.00 |
> |          2018 | 24000.00 |  1000.00 |
> |          2019 | 26000.00 |  1000.00 |
> |          2020 | 28000.00 |  1000.00 |
> |          2021 | 30000.00 |  1000.00 |
> |          2022 | 32000.00 |  1000.00 |
> |          2023 | 34000.00 |  1000.00 |
> |          2024 | 36000.00 |  1000.00 |
> |          2025 | 38000.00 |  1000.00 |
> |          2026 | 40000.00 |  1000.00 |
> |          2027 | 42000.00 |  1000.00 |
> |          2028 | 44000.00 |  1000.00 |
> |          2029 | 46000.00 |  1000.00 |
> |          2030 | 48000.00 |  1000.00 |
> |---------------+----------+----------|
> After reading a related SO question I tried the formula
>
> #+TBLFM: @<<<..>$2=@<<..>>$2+2*$3
>
> but it doesn't work. It gives an error and also seems to operate on
> column one instead of the specified column two. Any idea how to
> correctly compute column two? I am using org-mode version 8.2.5c with
> Emacs version 24.5.1.
>
> Disclaimer: I posted this question also on Stack Overflow:
>
>
> http://stackoverflow.com/questions/33063425/recursive-formulaes-in-org-mode-tables
>
> Feel free to answer here or there.
>
> Thanks!
>
> Best,
> Michael
>
>
>

[-- Attachment #2: Type: text/html, Size: 5572 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Recursive formulaes in org-mode tables
  2015-10-13 15:35 Recursive formulaes in org-mode tables michael.zombok
  2015-10-13 17:17 ` Shankar Rao
@ 2015-10-14  6:42 ` Eric S Fraga
  2015-10-14 14:55   ` Basil Komboz
  1 sibling, 1 reply; 4+ messages in thread
From: Eric S Fraga @ 2015-10-14  6:42 UTC (permalink / raw)
  To: michael.zombok; +Cc: emacs-orgmode

On Tuesday, 13 Oct 2015 at 17:35, michael.zombok@googlemail.com wrote:

[...]

> After reading a related SO question I tried the formula
>
> #+TBLFM: @<<<..>$2=@<<..>>$2+2*$3

This worked for me:

    #+TBLFM: @<<<$2..@>$2=@-1+2*@-1$+1

HTH,
eric
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.2-161-gd2ac25

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Recursive formulaes in org-mode tables
  2015-10-14  6:42 ` Eric S Fraga
@ 2015-10-14 14:55   ` Basil Komboz
  0 siblings, 0 replies; 4+ messages in thread
From: Basil Komboz @ 2015-10-14 14:55 UTC (permalink / raw)
  To: michael.zombok; +Cc: emacs-orgmode

Thanks to both of you for the solutions!

Best

    Eric> On Tuesday, 13 Oct 2015 at 17:35, michael.zombok@googlemail.com wrote:
    Eric> [...]

    >> After reading a related SO question I tried the formula
    >> 
    >> #+TBLFM: @<<<..>$2=@<<..>>$2+2*$3

    Eric> This worked for me:

    Eric>     #+TBLFM: @<<<$2..@>$2=@-1+2*@-1$+1

    Eric> HTH, eric -- : Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org
    Eric> release_8.3.2-161-gd2ac25

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-14 14:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-13 15:35 Recursive formulaes in org-mode tables michael.zombok
2015-10-13 17:17 ` Shankar Rao
2015-10-14  6:42 ` Eric S Fraga
2015-10-14 14:55   ` Basil Komboz

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).