From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cecil Westerhof Subject: Re: Sub-totals Date: Wed, 19 Feb 2014 06:00:48 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c123b6b2be6404f2bb453f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFzH8-0006ee-W1 for emacs-orgmode@gnu.org; Wed, 19 Feb 2014 00:00:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFzH7-000174-Qk for emacs-orgmode@gnu.org; Wed, 19 Feb 2014 00:00:50 -0500 Received: from mail-qg0-x22b.google.com ([2607:f8b0:400d:c04::22b]:44321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFzH7-000170-L1 for emacs-orgmode@gnu.org; Wed, 19 Feb 2014 00:00:49 -0500 Received: by mail-qg0-f43.google.com with SMTP id f51so8561828qge.2 for ; Tue, 18 Feb 2014 21:00:49 -0800 (PST) In-Reply-To: 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: emacs-orgmode@gnu.org --001a11c123b6b2be6404f2bb453f Content-Type: text/plain; charset=ISO-8859-1 2014-02-16 10:06 GMT+01:00 Michael Brand : > > - I would like to have only the last element of the range filled. > > I always thought that this would not be possible with reasonable > effort. Your question made me think again and it is possible, now I > can change my own use cases with sub-total :-) . See docstring and > take the procedure with vlen etc. from the TBLFM of the new ERT > test-org-table/sub-total here: > > http://orgmode.org/w/org-mode.git?p=org-mode.git;a=blob;f=testing/lisp/test-org-table.el > > Or read the docstring there and just take this copy that I used to > build the ERT: > |-------+-------+-------| > | Item | Item | Sub- | > | name | value | total | > |-------+-------+-------| > | a1 | 4.1 | | > | a2 | 8.2 | | > | a3 | | 12.3 | > |-------+-------+-------| > | b1 | 16.0 | 16.0 | > |-------+-------+-------| > | c1 | 32 | | > | c2 | 64 | 96.0 | > |-------+-------+-------| > | Total | 124.3 | | > |-------+-------+-------| > #+TBLFM: @>$2 = vsum(@II..@>>) :: $3 = if(vlen(@-I$2..@0$2) == > vlen(@-I$2..@+I$2), vsum(@-I$2..@+I$2) +.0, string("")); EN f-1 :: > @>$3 = string("") > I made: #+TBLFM: @>$2 = vsum(@<<..@>>) :: @<<$3..@>>$3 = if(vlen(@-I$2..@0$2) == vlen(@-I$2..@+I$2), vsum(@-I$2..@+I$2), string("")) -- Cecil Westerhof --001a11c123b6b2be6404f2bb453f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

2014-02-16 10:06 GMT+01:00 Michael Brand <michael.ch.brand@g= mail.com>:
> - I would like to ha= ve only the last element of the range filled.

I always thought that this would not be possible with reasonable
effort. Your question made me think again and it is possible, now I
can change my own use cases with sub-total :-) . See docstring and
take the procedure with vlen etc. from the TBLFM of the new ERT
test-org-table/sub-total here:
http://orgmode.org/w/org-= mode.git?p=3Dorg-mode.git;a=3Dblob;f=3Dtesting/lisp/test-org-table.el
Or read the docstring there and just take this copy that I used to
build the ERT:
|-------+-------+-------|
| Item =A0| =A0Item | =A0Sub- |
| name =A0| value | total |
|-------+-------+-------|
| a1 =A0 =A0| =A0 4.1 | =A0 =A0 =A0 |
| a2 =A0 =A0| =A0 8.2 | =A0 =A0 =A0 |
| a3 =A0 =A0| =A0 =A0 =A0 | =A012.3 |
|-------+-------+-------|
| b1 =A0 =A0| =A016.0 | =A016.0 |
|-------+-------+-------|
| c1 =A0 =A0| =A0 =A032 | =A0 =A0 =A0 |
| c2 =A0 =A0| =A0 =A064 | =A096.0 |
|-------+-------+-------|
| Total | 124.3 | =A0 =A0 =A0 |
|-------+-------+-------|
#+TBLFM: @>$2 =3D vsum(@II..@>>) :: $3 =3D if(vlen(@-I$2..@0$2) = =3D=3D
vlen(@-I$2..@+I$2), vsum(@-I$2..@+I$2) +.0, string("")); EN f-1 := :
@>$3 =3D string("")

I ma= de:
=A0=A0=A0 #+TBLFM: @>$2 =3D vsum(@<<..@>>) :: @<&l= t;$3..@>>$3 =3D if(vlen(@-I$2..@0$2) =3D=3D vlen(@-I$2..@+I$2), vsum(= @-I$2..@+I$2), string(""))

--
Cecil Westerhof
--001a11c123b6b2be6404f2bb453f--