From mboxrd@z Thu Jan  1 00:00:00 1970
From: Cecil Westerhof <cldwesterhof@gmail.com>
Subject: Re: Sub-totals
Date: Wed, 19 Feb 2014 06:00:48 +0100
Message-ID: <CAG-LmmA4r=m+cY_YhgiJjoFYnEgdbv_PiyteM8M+dBjFfzrY8w@mail.gmail.com>
References: <CAG-LmmC4-3f8UN+vQn3Hg7vAc51Qsv2m-L4or8DN0ZdmmoYB+Q@mail.gmail.com>
	<CALn3zoi0hx=7CFPC1p+0ctzhYJ7w+n1-p4hvvBxPKLBxd4u6-Q@mail.gmail.com>
	<CAG-LmmBU8V+dxH0g8ROqetjU+ZyzScN92Bks_+JXjFGUUnnndQ@mail.gmail.com>
	<CALn3zohYS2i+=1okH=6pyBfBRYGhOmLbWaQKj1TJZnVsGM_wFA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11c123b6b2be6404f2bb453f
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org>
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34929)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <cldwesterhof@gmail.com>) 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 <cldwesterhof@gmail.com>) 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 <cldwesterhof@gmail.com>) 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 <emacs-orgmode@gnu.org>; Tue, 18 Feb 2014 21:00:49 -0800 (PST)
In-Reply-To: <CALn3zohYS2i+=1okH=6pyBfBRYGhOmLbWaQKj1TJZnVsGM_wFA@mail.gmail.com>
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=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 <michael.ch.brand@gmail.com>:

> > - 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

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:courier =
new,monospace"><br></div><div class=3D"gmail_extra"><div class=3D"gmail_quo=
te">2014-02-16 10:06 GMT+01:00 Michael Brand <span dir=3D"ltr">&lt;<a href=
=3D"mailto:michael.ch.brand@gmail.com" target=3D"_blank">michael.ch.brand@g=
mail.com</a>&gt;</span>:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">&gt; - I would like to ha=
ve only the last element of the range filled.<br><div class=3D"">
<br>
</div>I always thought that this would not be possible with reasonable<br>
effort. Your question made me think again and it is possible, now I<br>
can change my own use cases with sub-total :-) . See docstring and<br>
take the procedure with vlen etc. from the TBLFM of the new ERT<br>
test-org-table/sub-total here:<br>
<a href=3D"http://orgmode.org/w/org-mode.git?p=3Dorg-mode.git;a=3Dblob;f=3D=
testing/lisp/test-org-table.el" target=3D"_blank">http://orgmode.org/w/org-=
mode.git?p=3Dorg-mode.git;a=3Dblob;f=3Dtesting/lisp/test-org-table.el</a><b=
r>
<br>
Or read the docstring there and just take this copy that I used to<br>
build the ERT:<br>
|-------+-------+-------|<br>
| Item =A0| =A0Item | =A0Sub- |<br>
| name =A0| value | total |<br>
|-------+-------+-------|<br>
| a1 =A0 =A0| =A0 4.1 | =A0 =A0 =A0 |<br>
| a2 =A0 =A0| =A0 8.2 | =A0 =A0 =A0 |<br>
| a3 =A0 =A0| =A0 =A0 =A0 | =A012.3 |<br>
|-------+-------+-------|<br>
| b1 =A0 =A0| =A016.0 | =A016.0 |<br>
|-------+-------+-------|<br>
| c1 =A0 =A0| =A0 =A032 | =A0 =A0 =A0 |<br>
| c2 =A0 =A0| =A0 =A064 | =A096.0 |<br>
|-------+-------+-------|<br>
| Total | 124.3 | =A0 =A0 =A0 |<br>
|-------+-------+-------|<br>
#+TBLFM: @&gt;$2 =3D vsum(@II..@&gt;&gt;) :: $3 =3D if(vlen(@-I$2..@0$2) =
=3D=3D<br>
vlen(@-I$2..@+I$2), vsum(@-I$2..@+I$2) +.0, string(&quot;&quot;)); EN f-1 :=
:<br>
@&gt;$3 =3D string(&quot;&quot;)<br></blockquote><div><br><div class=3D"gma=
il_default" style=3D"font-family:courier new,monospace;display:inline">I ma=
de:<br>=A0=A0=A0 #+TBLFM: @&gt;$2 =3D vsum(@&lt;&lt;..@&gt;&gt;) :: @&lt;&l=
t;$3..@&gt;&gt;$3 =3D if(vlen(@-I$2..@0$2) =3D=3D vlen(@-I$2..@+I$2), vsum(=
@-I$2..@+I$2), string(&quot;&quot;))<br>
</div></div></div><br>-- <br>Cecil Westerhof
</div></div>

--001a11c123b6b2be6404f2bb453f--