emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marco Wahl <marcowahlsoft@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: problem with lookup, count several string in one (or more) columns.
Date: Tue, 05 Jul 2016 15:47:41 +0200	[thread overview]
Message-ID: <84lh1g5h8i.fsf@gmail.com> (raw)
In-Reply-To: 874m84gtqn.fsf@mat.ucm.es

Uwe Brauer <oub@mat.ucm.es> writes:

> You mean
>
> | group | round 1 | round 2 |
> |-------+---------+---------|
> | A     |         |     2.4 |
> | B     | 4.7     |      11 |
> | C     |         |      MH |
> | D     | 5       |         |
> | E     |         |     7.2 |
> | F     | 3.2     |     4.3 |
> | G     | NP      |     4.4 |
> | H     | NP      |       8 |
> | I     | NP      |       8 |
> |-------+---------+---------|
> | total | MH      |       4 |
>
> #+TBLFM: @>$3='(+ (length(org-lookup-all "NP" '(@2$2..@-1$3) nil)) (length(org-lookup-all "MH" '(@2$2..@-1$3) nil)));

Yes.

> That gives
>
> | total | MH      |  4       |

Agreed.

> But I want
>
> | total | MH | 1 |
> | total | NP | 3 |

Okay.

What about the following?

 | group | round 1 | round 2 |
 |-------+---------+---------|
 | A     |         |     2.4 |
 | B     | 4.7     |      11 |
 | C     |         |      MH |
 | D     | 5       |         |
 | E     |         |     7.2 |
 | F     | 3.2     |     4.3 |
 | G     | NP      |     4.4 |
 | H     | NP      |       8 |
 | I     | NP      |       8 |
 |-------+---------+---------|
 | total | MH      |         |
 | total | NP      |         |
#+TBLFM: @>>$3='(length(org-lookup-all "MH" '(@2$2..@-1$3) nil))::@>$3='(length(org-lookup-all "NP" '(@2$2..@-2$3) nil))

Or the sightly more general formula afaics:

#+TBLFM: @>>$3='(length(org-lookup-all "MH" '(@2$2..@-I$3) nil))::@>$3='(length(org-lookup-all "NP" '(@2$2..@-I$3) nil))


Best regards,
--
https://marcowahl.github.io

  reply	other threads:[~2016-07-05 13:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04 19:57 problem with lookup, count several string in one (or more) columns Uwe Brauer
2016-07-05  6:50 ` Marco Wahl
2016-07-05 12:22   ` Uwe Brauer
2016-07-05 13:47     ` Marco Wahl [this message]
2016-07-05 14:53       ` Uwe Brauer

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=84lh1g5h8i.fsf@gmail.com \
    --to=marcowahlsoft@gmail.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).