From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: tables: sum columns only in certain ranges of rows Date: Thu, 07 Jul 2016 12:28:22 -0400 Message-ID: <8737nlv2e1.fsf@alphaville.usersys.redhat.com> References: <87oa6db4kx.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLCAG-0001Ib-7S for emacs-orgmode@gnu.org; Thu, 07 Jul 2016 12:28:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLCAC-0006tV-8i for emacs-orgmode@gnu.org; Thu, 07 Jul 2016 12:28:36 -0400 Received: from plane.gmane.org ([80.91.229.3]:34625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLCAC-0006tI-1h for emacs-orgmode@gnu.org; Thu, 07 Jul 2016 12:28:32 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1bLCAA-0001rz-4T for emacs-orgmode@gnu.org; Thu, 07 Jul 2016 18:28:30 +0200 Received: from nat-pool-bos-t.redhat.com ([66.187.233.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Jul 2016 18:28:30 +0200 Received: from ndokos by nat-pool-bos-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Jul 2016 18:28:30 +0200 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" To: emacs-orgmode@gnu.org Michael Brand writes: > Hi Uwe > > On Mon, Jul 4, 2016 at 9:12 PM, Uwe Brauer wrote: > >> Is the a simple way to tell a org-table that >> it adds say two columns in a certain way $4=0.2*($2+$3) >> but only for certain values of the row. I hoped that >> a hline would help but it does not the row containing Taylor >> is treated in the same way as row 1 to 4. >> >> >> | Row | Name | E1 | E2 | Res | >> |-----+--------+----+----+-----| >> | 1 | Smith | 1 | 2 | 0.6 | >> | 2 | Miller | 2 | 1 | 0.6 | >> | 3 | Meyer | 1 | 4 | 1. | >> | 4 | Wilson | 2 | 1 | 0.6 | >> |-----+--------+----+----+-----| >> | 5 | Taylor | 1 | 2 | 0.6 | >> |-----+--------+----+----+-----| >> #+TBLFM: $1=@#-1::$5=0.2*($3+$4) >> >> >> So what is the most comfortable to obtain what I want? > > Depending on what you want you can use $5 = if($1 != 5, 0.2*($3+$4), > string("")). See also some other examples with if in the Org manual. > > Michael > > This seems to work: --8<---------------cut here---------------end--------------->8--- #+TBLFM: $1=@#-1::@2$5..@5$5=0.2*($3+$4) --8<---------------cut here---------------end--------------->8--- -- Nick