From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: how to refer row's by name in a spreadsheet formula? Date: Fri, 08 Jul 2011 10:14:50 +0200 Message-ID: <87wrft5gud.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:38175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qf6Cg-0006tG-KV for emacs-orgmode@gnu.org; Fri, 08 Jul 2011 04:14:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qf6Ce-0002jx-4q for emacs-orgmode@gnu.org; Fri, 08 Jul 2011 04:14:26 -0400 Received: from mail-fx0-f52.google.com ([209.85.161.52]:34373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qf6Cd-0002jq-NN for emacs-orgmode@gnu.org; Fri, 08 Jul 2011 04:14:24 -0400 Received: by fxd18 with SMTP id 18so1697030fxd.39 for ; Fri, 08 Jul 2011 01:14:22 -0700 (PDT) In-Reply-To: (jiangzuoyan@gmail.com's message of "Thu, 7 Jul 2011 16:44:33 +0800") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "jiangzuoyan@gmail.com" Cc: emacs-org Hi Jiang, "jiangzuoyan@gmail.com" writes: > Formulas reference in a long table are very easy corrupted by > manually inserting. so, I think, refer using name instead of num. is > better. > > but how to refer the rows by name? > > For example, > > |---+------+---------+--------+---------+------| > | ! | date | amount  | item   | account | note | > |   | date | amount  | item   | account | note | > |---+------+---------+--------+---------+------| > | _ |      | bamount |        |         |      | > |   |      | 12      | lunch  | pocket  |      | > |   |      | 59      | dinner | pocket  |      | > | ^ |      | eamount |        |         |      | > |---+------+---------+--------+---------+------| > | _ |      | total   |        |         |      | > | # |      | #ERROR  |        |         |      | > |---+------+---------+--------+---------+------| > #+TBLFM: $total=vsum($bamount..$eamount);%.2f > > I'd expected $bamount..$eamount is the range of > @II$amount..@III$amount, but it's not. $bamount and $eamount are > epxanded to the values too early. I see the problem you have. To my understanding, field names like "bamount" and "eamount" refer to the _value_ of the above/below field, not to the _position_. So when the formula is computed, these names are replaced by values, not by position -- hence the result you have. I'm not sure this is by design. Maybe Carsten can tell more, and/or have a look in this issue when he's back. Best, -- Bastien