From: Michael Brand <michael.ch.brand@gmail.com>
To: Karl Voit <news1142@karl-voit.at>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Tables: remote reference fails with umlaut (and in other cases)
Date: Mon, 25 Jan 2016 18:57:06 +0100 [thread overview]
Message-ID: <CALn3zogjENjMpSyErPx3bK5hMNpnmq=HHCO9hKbyeQ8CmQGCcQ@mail.gmail.com> (raw)
In-Reply-To: <2016-01-25T15-45-54@devnull.Karl-Voit.at>
[-- Attachment #1: Type: text/plain, Size: 2044 bytes --]
Hi Karl
> I tried to reference "the item one row up" via @@#-1$1 (and similar)
> and failed. Is there a way to accomplish this as well?
It fails because @@#-1$1 is only substituted with @1-1$1, @2-1$1 etc.
depending on the row it is evaluated on.
To be able to use an expression as the index for an indirection one
can select the element from a Calc vector or Lisp list. For a Calc
formula example please e. g. look for the Calc function subscr() in
http://orgmode.org/worg/org-hacks.html#field-coordinates-in-formulas
Beware of the formula modifier E to keep empty fields counting for the
position:
| 1 | | |
|---+-----+---|
| 2 | 1 | 1 |
| | 2 | 2 |
| 4 | nan | 4 |
#+TBLFM: $2 = subscr(@<$1..@>$1, @# - 1); E :: $3 = subscr(@<$1..@>$1, @# - 1)
| 1st | | |
|-----+-----+-----|
| 2nd | 1st | 1st |
| | 2nd | 2nd |
| 4th | | 4th |
#+TBLFM: $2 = '(nth (- @# 2) '(@<$1..@>$1)); E :: $3 = '(nth (- @# 2)
'(@<$1..@>$1))
>>> [1] https://github.com/novoid/org-mode-workshop/blob/master/featureshow/org-mode-teaser.org#1131-referencing-example-with-detailed-explanation
>>
>> Do you remember that some time ago I reminded you about a patch that I
>> had sent you privately to align your above URL with the change about how
>> to copy fields in the Org manual?
>
> A big sorry from my side: I did not process your email for too many
> months. Thanks for contributing to my tutorial!
Thank you for applying my patch for the section "column-based".
Attached is another patch for the section "row-based" which I somehow
missed in the first place.
The sentence "the identity statement prevents calc from interpreting
the content" that you added might be misleading because the formula is
now a Lisp formula '(func ...), with a mandatory function in its first
place and Calc is not involved.
Btw. I failed to find a Calc formula as capable as the Lisp formula to
copy content one to one. Some time ago I documented my trials into
this direction in test-org-table/copy-field in
testing/lisp/test-org-table.el.
Michael
[-- Attachment #2: row-based.diff --]
[-- Type: text/plain, Size: 1904 bytes --]
diff --git a/featureshow/org-mode-teaser.org b/featureshow/org-mode-teaser.org
index 1d4305a..0d949ca 100644
--- a/featureshow/org-mode-teaser.org
+++ b/featureshow/org-mode-teaser.org
@@ -735,24 +735,24 @@ The formular can be simplified even more by using a column formula:
#+NAME: comparison-table-horizontal
| | Joe | Alice | Bob | sum |
-| 2012 Income June | 10 | 24 | 17 | 51 |
+| Income June 2012 | 10 | 24 | 17 | 51 |
| plus 20 percent | 12.0 | 28.8 | 20.4 | 60.0 |
| June 2013 | 11 | 31 | 21 | |
| Difference | -1.0 | 2.2 | 0.6 | 1.8 |
-#+TBLFM: @>$>=vsum(@5$2..@5$4)::@1$2..@1$4=remote(Income2012h, @1$$#)::@2=remote(Income2012h, @3$$#)::@3$2..@3$4=1.2 * remote(Income2012h, @3$$#);%.1f::@5$2..@5$4=@4-@3;%.1f
+#+TBLFM: @>$>=vsum(@5$2..@5$4)::@1$2..@1$4='(identity remote(Income2012h, @1$$#))::@2='(identity remote(Income2012h, @3$$#))::@3$2..@3$4=1.2 * remote(Income2012h, @3$$#);%.1f::@5$2..@5$4=@4-@3;%.1f
- all formulas explained in detail:
- ~@>$>=vsum(@5$2..@5$4)~
- value: ~1.8~
- last column in last row (~@>$>~) is the vector-sum (~vsum~) of
column two to four of fifth row (~@5$2..@5$4~)
- - ~@1$2..@1$4=remote(Income2012h, @1$$#)~
+ - ~@1$2..@1$4='(identity remote(Income2012h, @1$$#))~
- values: ~Joe | Alice | Bob | sum~
- column two to four of first row (~@1$2..@1$4~) are copied from
the corresponding fields of the first row (~@1$$#~) of table
"Income2012h"
- see also [[http://orgmode.org/worg/org-hacks.html#field-coordinates-in-formulas][Org-hacks]] for field formulas
- - ~@2=remote(Income2012h, @3$$#)~
+ - ~@2='(identity remote(Income2012h, @3$$#))~
- values: ~2012 Income June | 10 | 24 | 17 | 51~
- the second row (~@2~) is copied from the corresponding fields of
the first row (~@1$$#~) of table "Income2012h"
next prev parent reply other threads:[~2016-01-25 17:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-19 13:10 Tables: remote reference fails with umlaut (and in other cases) Karl Voit
2016-01-19 15:12 ` Eric S Fraga
2016-01-19 15:29 ` Karl Voit
2016-01-19 19:04 ` Michael Brand
2016-01-25 14:48 ` Karl Voit
2016-01-25 17:57 ` Michael Brand [this message]
2016-01-19 16:40 ` Nick Dokos
2016-01-19 22:28 ` Stefan Huchler
2016-01-20 12:01 ` Karl Voit
2016-01-19 16:32 ` Stefan Huchler
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='CALn3zogjENjMpSyErPx3bK5hMNpnmq=HHCO9hKbyeQ8CmQGCcQ@mail.gmail.com' \
--to=michael.ch.brand@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=news1142@karl-voit.at \
/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.