From mboxrd@z Thu Jan 1 00:00:00 1970 From: William Denton Subject: Using org-lookup-all to count values in a table column Date: Tue, 24 Sep 2013 13:42:34 -0400 (EDT) Message-ID: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOWdE-0001fE-Ls for emacs-orgmode@gnu.org; Tue, 24 Sep 2013 13:42:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOWdA-0006eG-5N for emacs-orgmode@gnu.org; Tue, 24 Sep 2013 13:42:40 -0400 Received: from shell.miskatonic.org ([65.39.236.119]:35618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOWdA-0006e3-1I for emacs-orgmode@gnu.org; Tue, 24 Sep 2013 13:42:36 -0400 Received: from wtd (helo=localhost) by shell.miskatonic.org with local-esmtp (Exim 4.72) (envelope-from ) id 1VOWd8-0004lJ-Lu for emacs-orgmode@gnu.org; Tue, 24 Sep 2013 13:42:34 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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/