From mboxrd@z Thu Jan 1 00:00:00 1970 From: Qiang Fang Subject: Re: Org table: how to reference part of the rows Date: Mon, 18 Dec 2017 09:04:44 +0800 Message-ID: References: <87vah5fj0q.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="089e082ea570a17867056092ef97" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQjrL-0003wd-Pr for emacs-orgmode@gnu.org; Sun, 17 Dec 2017 20:04:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQjrK-0007B0-R6 for emacs-orgmode@gnu.org; Sun, 17 Dec 2017 20:04:47 -0500 Received: from mail-pl0-x236.google.com ([2607:f8b0:400e:c01::236]:34589) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQjrK-00078a-JY for emacs-orgmode@gnu.org; Sun, 17 Dec 2017 20:04:46 -0500 Received: by mail-pl0-x236.google.com with SMTP id d21so3844715pll.1 for ; Sun, 17 Dec 2017 17:04:46 -0800 (PST) In-Reply-To: <87vah5fj0q.fsf@gmail.com> 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: Qiang Fang , emacs-orgmode@gnu.org --089e082ea570a17867056092ef97 Content-Type: text/plain; charset="UTF-8" I solved my problem by specifying the column range #+tblfm: @2$4..@-2$4 = ($3 / $2) * 100 On Sun, Dec 17, 2017 at 11:53 PM, Eric S Fraga wrote: > On Saturday, 16 Dec 2017 at 19:24, Qiang Fang wrote: > > The last column is the ratio between column b and a, the last row is > > the sum of each row, the second formula only applies from the second > > row to the row before last row. The table that doesn't work is: > > > > | | a | b | ratio | > > | | 0.797 | 0.780 | | > > | | 0.744 | 0.730 | | > > | | 12.707 | 2.384 | | > > | sum | 14.248 | 3.114 | 0.92040988 | > > | ^ | x | y | | > > #+tblfm: $x=vsum(@2..@-1) :: $y=vsum(@3..@-1) > > #+tblfm: $4 = ($3 / $2) * 100 > > I cannot help with the OP's question but this table leads to very > strange behaviour for me. If I delete the tblfm lines, then go to the > location of the x variable (5th row, 2nd column) and type C-u C-c = to > enter "x=vsum(@2..@i-1)", that is okay. But if I then go to the next > column and try to enter the equivalent formula for y, it replaces the > previously entered formula for x! If I go back to the x location and > re-enter that formula, it replaces the y formula. > > Further, the formulae created by org are missing the $ in front of the > variable, i.e. x=vsum(...) instead of $x=vsum(...). > > This happens with up to date org from git as of an hour or so ago. > > For the OP, the formulas > > -- > Eric S Fraga via Emacs 27.0.50, Org release_9.1.4-214-ge8b71b > --089e082ea570a17867056092ef97 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I solved my problem by specifying the column range
=C2= =A0#+tblfm: @2$4..@-2$4 =3D ($3 / $2) * 100


On Sun, Dec 17, 2017 at 11:53 PM, = Eric S Fraga <esflists@gmail.com> wrote:
On Saturday, 16 Dec= 2017 at 19:24, Qiang Fang wrote:
> The last column is the ratio between column b and a, the last row is > the sum of each row, the second formula only applies from the second > row to the row before last row. The table that doesn't work is: >
>=C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 a |=C2= =A0 =C2=A0 =C2=A0b |=C2=A0 =C2=A0 =C2=A0 ratio |
>=C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0|=C2=A0 0.797 | 0.780 |=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
>=C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0|=C2=A0 0.744 | 0.730 |=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
>=C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0| 12.707 | 2.384 |=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
>=C2=A0 =C2=A0 =C2=A0| sum | 14.248 | 3.114 | 0.92040988 |
>=C2=A0 =C2=A0 =C2=A0| ^=C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 x |=C2=A0 =C2= =A0 =C2=A0y |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
>=C2=A0 =C2=A0 =C2=A0#+tblfm: $x=3Dvsum(@2..@-1) :: $y=3Dvsum(@3..@-1) >=C2=A0 =C2=A0 =C2=A0#+tblfm: $4 =3D ($3 / $2) * 100

I cannot help with the OP's question but this table leads t= o very
strange behaviour for me.=C2=A0 If I delete the tblfm lines, then go to the=
location of the x variable (5th row, 2nd column) and type C-u C-c =3D to enter "x=3Dvsum(@2..@i-1)", that is okay.=C2=A0 But if I then go = to the next
column and try to enter the equivalent formula for y, it replaces the
previously entered formula for x!=C2=A0 If I go back to the x location and<= br> re-enter that formula, it replaces the y formula.

Further, the formulae created by org are missing the $ in front of the
variable, i.e. x=3Dvsum(...) instead of $x=3Dvsum(...).

This happens with up to date org from git as of an hour or so ago.

For the OP, the formulas

--
Eric S Fraga via Emacs 27.0.50, Org release_9.1.4-214-ge8b71b

--089e082ea570a17867056092ef97--