emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-table relative reference questions
@ 2015-04-20 13:35 Jeffrey Brent McBeth
  2015-04-20 14:38 ` Jeffrey Brent McBeth
  2015-04-21  8:13 ` Michael Brand
  0 siblings, 2 replies; 4+ messages in thread
From: Jeffrey Brent McBeth @ 2015-04-20 13:35 UTC (permalink / raw)
  To: emacs-orgmode

I'm looking for a way to reference a row or column on both the left side and right side of a table formula that is "easily" manipulable.  

At first, I thought the hline references would work for me @I..@II, except they cannot be used on the left side of an equation.  I hoped that maybe named fields would work (^,_), but those are apparently value aliases and not location references.

Essentially, I want to keep a single table in which I can enter and calculate data, and limit the computation to start at a given row that I change as I go along.  Maybe I'm simply using the wrong tool for this, excel is certainly not capable; so if org-table isn't either, it certainly doesn't lessen it.

#+BEGIN_EXAMPLE

| F |  A |  B |  C |
|---+----+----+----|
| _ | tA | tB | tC |
|   |  1 |  3 | 42 |
|   |  2 |  4 | 69 |
|---+----+----+----|
| # |    |    |    |
#+TBLFM=@>$2=vsum(@tA..@II)::$tC=$-2+$-1

| F |  A |  B |  C |
|---+----+----+----|
|   |  1 |  3 | 42 |
| _ | tA | tB | tC |
|   |  2 |  4 | 69 |
|---+----+----+----|
| # |    |    |    |
#+TBLFM=@>$2=vsum(@tA..@II)::$tC=$-2+$-1

#+END_EXAMPLE




-- 
"The man who does not read good books has no advantage over 
 the man who cannot read them."
 -- Mark Twain

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

* Re: org-table relative reference questions
  2015-04-20 13:35 org-table relative reference questions Jeffrey Brent McBeth
@ 2015-04-20 14:38 ` Jeffrey Brent McBeth
  2015-04-21  8:13 ` Michael Brand
  1 sibling, 0 replies; 4+ messages in thread
From: Jeffrey Brent McBeth @ 2015-04-20 14:38 UTC (permalink / raw)
  To: emacs-orgmode

On Mon, Apr 20, 2015 at 09:35:28AM -0400, Jeffrey Brent McBeth wrote:
> I'm looking for a way to reference a row or column on both the left side and right side of a table formula that is "easily" manipulable.  
> 
> At first, I thought the hline references would work for me @I..@II, except they cannot be used on the left side of an equation.  I hoped that maybe named fields would work (^,_), but those are apparently value aliases and not location references.

<snip>

To be clear, for my use case, I think functional hline references on the left side would be sufficient.  I started going down the ^_ route because I thought it might give me an out, the notation is tons messier.

Jeffrey McBeth

-- 
"The man who does not read good books has no advantage over 
 the man who cannot read them."
 -- Mark Twain

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

* Re: org-table relative reference questions
  2015-04-20 13:35 org-table relative reference questions Jeffrey Brent McBeth
  2015-04-20 14:38 ` Jeffrey Brent McBeth
@ 2015-04-21  8:13 ` Michael Brand
  2015-04-21 14:43   ` Jeffrey Brent McBeth
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Brand @ 2015-04-21  8:13 UTC (permalink / raw)
  To: Jeffrey Brent McBeth; +Cc: Org Mode

Hi Jeffrey

On Mon, Apr 20, 2015 at 3:35 PM, Jeffrey Brent McBeth <mcbeth@broggs.org> wrote:
> I'm looking for a way to reference a row or column on both the left
> side and right side of a table formula that is "easily" manipulable.

As you noticed the left side is very limited compared to the right
side. The solution below keeps the left side simple. "x" is used as a
movable marker to indicate the beginning of the range:

| F | A | B |  C |
|---+---+---+----|
| x | 1 | 3 |  4 |
|   | 2 | 4 | 69 |
|---+---+---+----|
|   | 3 |   |    |
#+TBLFM: @>$2 = vsum(subvec(@I$2..@II$2, find(@I$1..@II$1, x), 0)); E
:: @<<$4..@>>$4 = if("$1" == "(x)", $-2 + $-1, $0)

| F | A | B |  C |
|---+---+---+----|
|   | 1 | 3 | 42 |
| x | 2 | 4 |  6 |
|---+---+---+----|
|   | 2 |   |    |
#+TBLFM: @>$2 = vsum(subvec(@I$2..@II$2, find(@I$1..@II$1, x), 0)); E
:: @<<$4..@>>$4 = if("$1" == "(x)", $-2 + $-1, $0)

For the details see the Org manual about spreadsheet and the Calc
manual.

Michael

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

* Re: org-table relative reference questions
  2015-04-21  8:13 ` Michael Brand
@ 2015-04-21 14:43   ` Jeffrey Brent McBeth
  0 siblings, 0 replies; 4+ messages in thread
From: Jeffrey Brent McBeth @ 2015-04-21 14:43 UTC (permalink / raw)
  To: emacs-orgmode

On Tue, Apr 21, 2015 at 10:13:53AM +0200, Michael Brand wrote:
> Hi Jeffrey
> 
> On Mon, Apr 20, 2015 at 3:35 PM, Jeffrey Brent McBeth <mcbeth@broggs.org> wrote:
> > I'm looking for a way to reference a row or column on both the left
> > side and right side of a table formula that is "easily" manipulable.
> 
> As you noticed the left side is very limited compared to the right
> side. The solution below keeps the left side simple. "x" is used as a
> movable marker to indicate the beginning of the range:
> 
> | F | A | B |  C |
> |---+---+---+----|
> | x | 1 | 3 |  4 |
> |   | 2 | 4 | 69 |
> |---+---+---+----|
> |   | 3 |   |    |
> #+TBLFM: @>$2 = vsum(subvec(@I$2..@II$2, find(@I$1..@II$1, x), 0)); E
> :: @<<$4..@>>$4 = if("$1" == "(x)", $-2 + $-1, $0)

That is awesome.  subvec and if seem to be two very powerful tools that I've missed as I've trawled the documentation.  Thank you so much.

Jeff

-- 
"The man who does not read good books has no advantage over 
 the man who cannot read them."
 -- Mark Twain

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

end of thread, other threads:[~2015-04-21 14:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-20 13:35 org-table relative reference questions Jeffrey Brent McBeth
2015-04-20 14:38 ` Jeffrey Brent McBeth
2015-04-21  8:13 ` Michael Brand
2015-04-21 14:43   ` Jeffrey Brent McBeth

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).