emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: William Denton <wtd@pobox.com>
To: emacs-orgmode@gnu.org
Subject: Using org-lookup-all to count values in a table column
Date: Tue, 24 Sep 2013 13:42:34 -0400 (EDT)	[thread overview]
Message-ID: <alpine.DEB.2.00.1309241336330.18295@shell.miskatonic.org> (raw)

I'm taking a stab at keeping my reading diary in Org.  I keep track of all 
the books I read, and some other facts about them, including whether 
they're fiction (F) or nonfiction (N).

So I would have a table something like the books table below, and I'd like 
to do some analysis on it and put the results in another table.  I'd like 
to count how many books are of Type F and how many of Type N, and it looks 
like matching values with org-lookup-all (as explained in [1]) is the 
right way, but I can't get it to work.

I have this:

#+TBLNAME: books
| Title            | Author         | Type |
|------------------+----------------+------|
| NOS4A2           | Joe Hill       | F    |
| Gun Machine      | Warren Ellis   | F    |
| Carry On, Jeeves | P.G. Wodehouse | F    |
| Time Reborn      | Lee Smolin     | N    |

#+TBLNAME: analysis
| Fact              | Value |
|-------------------+-------|
| Fiction books     |     1 |
| Nonfiction  books |       |
#+TBLFM: $2@2='(length(org-lookup-all "F" '(remote(books,$3@2..$3@>)) nil))

The fiction count should be 3, not 1.  Can anyone see what I'm doing 
wrong?

Thanks,

Bill

[1] http://orgmode.org/worg/org-tutorials/org-lookups.html

-- 
William Denton
Toronto, Canada
http://www.miskatonic.org/

             reply	other threads:[~2013-09-24 17:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-24 17:42 William Denton [this message]
2013-09-25 15:03 ` Using org-lookup-all to count values in a table column William Denton

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=alpine.DEB.2.00.1309241336330.18295@shell.miskatonic.org \
    --to=wtd@pobox.com \
    --cc=emacs-orgmode@gnu.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).