emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* problem with lookup, count several string in one (or more) columns.
@ 2016-07-04 19:57 Uwe Brauer
  2016-07-05  6:50 ` Marco Wahl
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2016-07-04 19:57 UTC (permalink / raw)
  To: emacs-orgmode



Hello

I tried to follow the instructions found in
http://orgmode.org/worg/org-tutorials/org-lookups.html

So I want to count all strings NP MH  in the following table
According to the instructions, the following will search the string MH.

| 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      |       1 |
#+TBLFM: @>$3='(length(org-lookup-all "MH" '(@2$2..@-1$3) nil));

So I could repeat that for the string NP as well but how can I search
for both (or more) strings at once?

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

* Re: problem with lookup, count several string in one (or more) columns.
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Wahl @ 2016-07-05  6:50 UTC (permalink / raw)
  To: emacs-orgmode

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

> Hello
>
> I tried to follow the instructions found in
> http://orgmode.org/worg/org-tutorials/org-lookups.html
>
> So I want to count all strings NP MH  in the following table
> According to the instructions, the following will search the string MH.
>
> | 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      |       1 |
>
> #+TBLFM: @>$3='(length(org-lookup-all "MH" '(@2$2..@-1$3) nil));
>
> So I could repeat that for the string NP as well but how can I search
> for both (or more) strings at once?

What about

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

?


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

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

* Re: problem with lookup, count several string in one (or more) columns.
  2016-07-05  6:50 ` Marco Wahl
@ 2016-07-05 12:22   ` Uwe Brauer
  2016-07-05 13:47     ` Marco Wahl
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2016-07-05 12:22 UTC (permalink / raw)
  To: emacs-orgmode

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

   > What about

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

   > ?

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)));

That gives

| total | MH      |  4       |


But I want


| total | MH | 1 |
| total | NP | 3 |

regards

Uwe 

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

* Re: problem with lookup, count several string in one (or more) columns.
  2016-07-05 12:22   ` Uwe Brauer
@ 2016-07-05 13:47     ` Marco Wahl
  2016-07-05 14:53       ` Uwe Brauer
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Wahl @ 2016-07-05 13:47 UTC (permalink / raw)
  To: emacs-orgmode

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

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

* Re: problem with lookup, count several string in one (or more) columns.
  2016-07-05 13:47     ` Marco Wahl
@ 2016-07-05 14:53       ` Uwe Brauer
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Brauer @ 2016-07-05 14:53 UTC (permalink / raw)
  To: emacs-orgmode


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

   > Yes.


   > Agreed.


   > 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      |         |

Great thanks a lot.

Uwe 

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

end of thread, other threads:[~2016-07-05 14:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2016-07-05 14:53       ` Uwe Brauer

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).