emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] questions about table mode and spreadsheets


From: Christian Moe
Subject: Re: [Orgmode] questions about table mode and spreadsheets
Date: Tue, 07 Sep 2010 00:44:03 +0200
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2

On 9/6/10 3:38 PM, Inquisitive Scientist wrote:

   2. How do I compute the sum of a column only if a corresponding row
matches some condition? For example, how do I compute the sum of
numbers in column a for which the name in column "name" is "bar"? For
example, I should get 7 for the sum in column a in the table below:

| name | a | b | c |
|------+---+---+---|
| foo  | 1 | 2 | 3 |
| bar  | 3 | 2 | 1 |
| bar  | 4 | 5 | 6 |
|------+---+---+---|

Here's one way: Add a new row after the first, as below. Then run C-c
C-c on the formula line:

| name |   | a | b | c |
|------+---+---+---+---|
| foo  |   | 1 | 2 | 3 |
| bar  |   | 3 | 2 | 1 |
| bar  |   | 4 | 5 | 6 |
|------+---+---+---+---|
|      |   |   |   |   |
#+TBLFM: $2='(if (string= $1 "bar") 1 0):: @5$3=vsum(vmask(@address@hidden,@address@hidden))

It does exactly what you asked, but I don't think it will scale well...

Cheers,
Christian


Thanks,
-I.S.



_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


--

Christian Moe
E-mail:  address@hidden
Website: http://christianmoe.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]