emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Brand <michael.ch.brand@gmail.com>
To: Jeffrey Brent McBeth <mcbeth@broggs.org>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: org-table relative reference questions
Date: Tue, 21 Apr 2015 10:13:53 +0200	[thread overview]
Message-ID: <CALn3zohvjdG3HW0fU1tyWxcFNf-FYGteToqt0jYM0piWBWA3wA@mail.gmail.com> (raw)
In-Reply-To: <20150420133528.GB16503@broggs.org>

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

  parent reply	other threads:[~2015-04-21  8:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2015-04-21 14:43   ` Jeffrey Brent McBeth

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://www.orgmode.org/

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

  git send-email \
    --in-reply-to=CALn3zohvjdG3HW0fU1tyWxcFNf-FYGteToqt0jYM0piWBWA3wA@mail.gmail.com \
    --to=michael.ch.brand@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mcbeth@broggs.org \
    /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 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).