From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eddward DeVilla" Subject: Re: Table calculation question Date: Sun, 26 Aug 2007 20:44:32 -0500 Message-ID: References: <871wdqhypu.fsf@gollum.intra.norang.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IPTei-0005OJ-5G for emacs-orgmode@gnu.org; Sun, 26 Aug 2007 21:44:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IPTed-0005C4-Be for emacs-orgmode@gnu.org; Sun, 26 Aug 2007 21:44:39 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IPTed-0005Bw-6V for emacs-orgmode@gnu.org; Sun, 26 Aug 2007 21:44:35 -0400 Received: from wa-out-1112.google.com ([209.85.146.177]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IPTec-0007UN-QA for emacs-orgmode@gnu.org; Sun, 26 Aug 2007 21:44:35 -0400 Received: by wa-out-1112.google.com with SMTP id j4so1840224wah for ; Sun, 26 Aug 2007 18:44:33 -0700 (PDT) In-Reply-To: <871wdqhypu.fsf@gollum.intra.norang.ca> Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bernt Hansen Cc: emacs-orgmode@gnu.org On 8/26/07, Bernt Hansen wrote: > In the following table I'd like to vertically sum the column and the > compute a new value based on that sum. > > |---+---+---+---+-------+---------| > | | A | B | C | Total | Details | > |---+---+---+---+-------+---------| > | # | 1 | 2 | 4 | 7 | Item 1 | > | # | 2 | 6 | 4 | 12 | Item 2 | > | # | 2 | 4 | 4 | 10 | Item 3 | > | # | 2 | 6 | 3 | 11 | Item 4 | > |---+---+---+---+-------+---------| > | # | | | | 40 | 400.00 | > | ^ | | | | tot | result | > | $ | | | | | kval=10 | > |---+---+---+---+-------+---------| > #+TBLFM: $5=$2+$3+$4::$tot=vsum(@-II..@-I)::$result=$tot*$kval;%.2f > > If I edit any of the values in columns A, B, C and do C-u C-c C-c then > the total (tot) value is recalculated but result is not. Doing C-u C-c > C-c a second time recalculates result based on the new tot value. > > Is there a way to do this in a single table recalculation? > > Thanks, > Bernt I have this in some of my tables. Right now I just live with it. The problem is you can't really have computed value dependent on other computed values. Either you can do I like I do when I feel lazy and recalculate until things stabilize or you can rewrite your formulas to not depend on other computed values. So in the case of tot, use tot = vsum(@-II$2..@-I$5) or something like that. (I don't have calc so I can't test this.) For now, I wish the table editor would highlight calculated cells or do something to let you know when you are calculating one field using another calculated field. I've been telling myself that I'm going to dig into the formula evaluator and see if I can't get it to inline formulas from other referenced cells so it will 'do the right thing'. I'm sure it not trivial and for now there is a work around. Edd