From mboxrd@z Thu Jan 1 00:00:00 1970 From: Uwe Brauer Subject: problems with tables using https://orgmode.org/worg/org-tutorials/org-lookups.html Date: Thu, 05 Apr 2018 17:56:23 +0200 Message-ID: <876055fxzs.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f47FX-0002A2-U8 for emacs-orgmode@gnu.org; Thu, 05 Apr 2018 11:56:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f47FU-0005Mg-Sa for emacs-orgmode@gnu.org; Thu, 05 Apr 2018 11:56:32 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:34986) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f47FU-0005MB-It for emacs-orgmode@gnu.org; Thu, 05 Apr 2018 11:56:28 -0400 Received: by mail-wm0-x235.google.com with SMTP id r82so8666469wme.0 for ; Thu, 05 Apr 2018 08:56:27 -0700 (PDT) Received: from Utnapischtim (gilgamesch.quim.ucm.es. [147.96.12.99]) by smtp.gmail.com with ESMTPSA id c14sm5859103wrd.17.2018.04.05.08.56.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Apr 2018 08:56:25 -0700 (PDT) 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" To: emacs-orgmode Hi I followed the instructions in https://orgmode.org/worg/org-tutorials/org-lookups.html #+BEGIN_SRC emacs-lisp (defun in-interval (bounds el) (and (>= el (car bounds)) (<= el (cadr bounds)))) #+END_SRC #+RESULTS: : in-interval And indeed #+TBLNAME: raw-data | | 4 | | | 4.25 | | | 4.5 | | | 4.5 | | | 5.5 | | | 5.5 | | | 5.5 | | | 5.75 | | | 6 | | | 6.5 | | | 7 | | | 7.5 | | | 9 | | lower bound | upper bound | frequency | |-------------+-------------+-----------| | 1 | 5 | 3 | | 5 | 10 | 9 | #+TBLFM: $3='(length (org-lookup-all '($1 $2) '(remote(raw-data,@2$2..@>$2)) nil 'in-interval));N Gives the desired result. However consider the following (slightly more complicated table). #+TBLNAME: raw-data2 |---+-----------------+-----+-----+-----+-----+-----+-----+-----| | | / | | <> | <> | <> | <> | <> | <> | | | Nombre Completo | DNI | Ej1 | Ej2 | Ej3 | Ej4 | Ej5 | Res | |---+-----------------+-----+-----+-----+-----+-----+-----+-----| | | Candidate1 | 1 | 0 | 5 | 5 | 0 | 10 | 2 | | | Candidate2 | 2 | 5 | 0 | 5 | 0 | 0 | 1 | | | Candidate3 | 3 | 0 | 0 | 0 | 20 | 25 | 4.5 | | | Candidate4 | 4 | 0 | 0 | 0 | 25 | 15 | 4 | | | Candidate5 | 5 | 15 | 15 | 20 | 25 | 25 | 10 | | | Candidate6 | 6 | 15 | 10 | 20 | 20 | 20 | 8.5 | | | Candidate7 | 7 | 15 | 10 | 10 | 20 | 15 | 7 | #+TBLFM: $9=($4+$5+$6+$7+$8)/10 | lower bound | upper bound | frequency | |-------------+-------------+-----------| | 1 | 5 | 0 | | 5 | 10 | 1 | #+TBLFM: $3='(length (org-lookup-all '($1 $2) '(remote(raw-data2,@9$9..@>$9)) nil 'in-interval));N And it does not work, Also #+TBLNAME: raw-data3 |---+-----------------+-----+-----+-----+-----+-----| | | / | <> | <> | <> | <> | <> | | | Nombre Completo | Ej1 | Ej2 | Ej3 | Ej4 | Res | |---+-----------------+-----+-----+-----+-----+-----| | | Candidate1 | 0 | 5 | 5 | 0 | 1 | | | Candidate2 | 5 | 0 | 5 | 0 | 1 | | | Candidate3 | 0 | 0 | 0 | 20 | 2 | | | Candidate4 | 0 | 0 | | 25 | 2.5 | | | Candidate5 | 15 | 15 | 20 | 25 | 7.5 | | | Candidate6 | 15 | 10 | 20 | 20 | 6.5 | | | Candidate7 | 15 | 0 | 10 | 20 | 4.5 | #+TBLFM: $7=($3+$4+$5+$6)/10 | lower bound | upper bound | frequency | |-------------+-------------+-----------| | 0 | 5 | 1 | | 5 | 10 | 2 | #+TBLFM: $3='(length (org-lookup-all '($1 $2) '(remote(raw-data3,@7$7..@>$7)) nil 'in-interval));N Does not work correctly? What is the problem? thanks Uwe Brauer