emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Referencing elemts of a table


From: Nick Dokos
Subject: Re: [O] Referencing elemts of a table
Date: Wed, 08 Jun 2011 00:25:11 -0400

kinouchou <address@hidden> 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 address@hidden' 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 <address@hidden>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, @address@hidden), $#)
> >
> > Michael
> >
> > On Tue, Jun 7, 2011 at 17:55, Karl Voit <address@hidden> 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,@address@hidden)
> > >
> > > and
> > >
> > >    #+TBLFM: @address@hidden(orgtblA,@address@hidden)
> > >
> > > 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/
> >
> >
> 




reply via email to

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