Org-mode mailing list
 help / color / mirror / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: kinouchou <kinouchou@gmail.com>
Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org
Subject: Re: Referencing elemts of a table
Date: Wed, 08 Jun 2011 00:25:11 -0400
Message-ID: <9128.1307507111@alphaville.dokosmarshall.org> (raw)
In-Reply-To: Message from kinouchou <kinouchou@gmail.com> of "Wed, 08 Jun 2011 02:05:51 +0200." <BANLkTikpNtd3S3aSpy4hkGkW9goXB+Jbnw@mail.gmail.com>

kinouchou <kinouchou@gmail.com> wrote:

> Do you know if it's possible for a table in another file? Because in the
> manuel i read it's possible but I don't have result.
> 
> (sorry for my english)
> Christelle
> 

I assume you mean the "remote references" in section 3.5.1 in the manual:

,----
| You may also reference constants, fields and ranges from a different
| table, either in the current file or even in a different file.  The
| syntax is
| 
|      remote(NAME-OR-ID,REF)
| 
| where NAME can be the name of a table in the current file as set by a
| `#+TBLNAME: NAME' line before the table.  It can also be the ID of an
| entry, even in a different file, and the reference then refers to the
| first table in that entry.  REF is an absolute field or range reference
| as described above for example `@3$3' or `$somename', valid in the
| referenced table.
`----

Here's a simple example - we have a table in one file, foo.org,
which refers to a cell in table with ID 17:
--8<---------------cut here---------------start------------->8---

* foo

#+TBLNAME: foo
|  a |   b |
|----+-----|
|  1 |   4 |
|  2 |   7 |
|  3 |  12 |
|  4 |  19 |
|  5 |  28 |
|  6 |  39 |
|  7 |  52 |
|  8 |  67 |
|  9 |  84 |
| 10 | 103 |

#+TBLFM: $2 = $1*$1 + remote(17, @4$1)
--8<---------------cut here---------------end--------------->8---

Here is the file that contains the table with ID 17 - the ID is
actually that of an entry and as the snippet of the manual says,
the remote reference refers to the first table under that entry.
Here we only have one table under the entry, so there is no
ambiguity:

--8<---------------cut here---------------start------------->8---


* bar
  :PROPERTIES:
  :ID:       17
  :END:

#+TBLNAME: bar
| a | b |
|---+---|
| 1 |   |
| 2 |   |
| 3 |   |
| 4 |   |
| 5 |   |
| 6 |   |
--8<---------------cut here---------------end--------------->8---

In practice, you would probably generate the ID with org-id-uuid
or similar to ensure that the ID is unique.

If you change the remote reference to e.g remote(17, @3$1) and
recalculate, you can see the values in the foo table changing
appropriately.

Does that answer your question?

Nick


> 
> On Tue, Jun 7, 2011 at 7:22 PM, Michael Brand <michael.ch.brand@gmail.com>wrote:
> 
> > Hi Karl
> >
> > You need additionally $# from "Field coordinates in formulas" described
> > here:
> > http://orgmode.org/manual/References.html#References
> > and Calc vector subscript:
> > #+TBLFM: @2 = subscr(remote(orgtblA, @2$2..@2$7), $#)
> >
> > Michael
> >
> > On Tue, Jun 7, 2011 at 17:55, Karl Voit <devnull@karl-voit.at> wrote:
> > > I want to define "orgtblB line 2 (row 1 to 6)" should contain the
> > > values "from orgtblA, last line, row 2 to 7".
> > >
> > > I tried
> > >
> > >    #+TBLFM: @2=remote(orgtblA,@2$2..@2$7)
> > >
> > > and
> > >
> > >    #+TBLFM: @2$1..@2$6=remote(orgtblA,@2$2..@2$7)
> > >
> > > but that results in a list of 6x 5 values in each field in row 2.
> > >
> > > Here is an example of my org-tbl-reference-problem:
> > > http://paste.grml.org/462/
> >
> >
> 

  parent reply	other threads:[~2011-06-08  4:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 15:55 Karl Voit
2011-06-07 17:22 ` Michael Brand
2011-06-08  0:05   ` kinouchou
2011-06-08  3:54     ` Jambunathan K
2011-06-08  4:25     ` Nick Dokos [this message]
2011-06-08 12:49   ` Karl Voit
2011-06-08 13:47     ` Michael Brand
     [not found]     ` <devnull@Karl-Voit.at>
2011-06-08 13:49       ` Nick Dokos

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

  List information: https://orgmode.org

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9128.1307507111@alphaville.dokosmarshall.org \
    --to=nicholas.dokos@hp.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=kinouchou@gmail.com \
    /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

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git