all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using org-lookup-all to count values in a table column
@ 2013-09-24 17:42 William Denton
  2013-09-25 15:03 ` William Denton
  0 siblings, 1 reply; 2+ messages in thread
From: William Denton @ 2013-09-24 17:42 UTC (permalink / raw
  To: emacs-orgmode

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/

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

* Re: Using org-lookup-all to count values in a table column
  2013-09-24 17:42 Using org-lookup-all to count values in a table column William Denton
@ 2013-09-25 15:03 ` William Denton
  0 siblings, 0 replies; 2+ messages in thread
From: William Denton @ 2013-09-25 15:03 UTC (permalink / raw
  To: emacs-orgmode

For the record I was mailed off-list and it was pointed out I had the 
row/column order reversed in my formula.

> #+TBLFM: $2@2='(length(org-lookup-all "F" '(remote(books,$3@2..$3@>)) nil))

Using @2$2 etc makes it all work.

Org spreadsheets are great!

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

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

end of thread, other threads:[~2013-09-25 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-24 17:42 Using org-lookup-all to count values in a table column William Denton
2013-09-25 15:03 ` William Denton

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.