From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adonay Felipe Nogueira Subject: Re: Calculating percentage Date: Sat, 15 Jul 2017 11:56:52 -0300 Message-ID: <87y3rpd9zf.fsf@openmailbox.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWPEn-0006zL-Ub for emacs-orgmode@gnu.org; Sat, 15 Jul 2017 11:44:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWPEk-0005aP-PZ for emacs-orgmode@gnu.org; Sat, 15 Jul 2017 11:44:09 -0400 Received: from lb1.openmailbox.org ([5.79.108.160]:58224 helo=mail.openmailbox.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dWPEk-0005SV-Ga for emacs-orgmode@gnu.org; Sat, 15 Jul 2017 11:44:06 -0400 In-Reply-To: (Cecil Westerhof's message of "Sat, 15 Jul 2017 07:06:15 +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 * If you want to calculate the percentage change Say, from [last row, first column] to [current row, first column], that is: ( current - last_in_table ) / last_in_table Then do either one of the following: a. Direct answer. Go below the table and insert (without the extra spaces): #+TBLFM: @2$2..@>>$2=3Drelch(@>$1, $1) * 100 b. Detailed answer. Go to any place inside the table and press C-c ', and insert (without the extra spaces): @2$2..@>>$2=3Drelch(@>$1, $1) * 100 "@" is row specification, "$" is column specification, ".." selects a range. Digits after "@" and "$" are absolute references (but as far as I can tell, these digits only count after the horizontal lines), ">" or "<" after these are relative to the last and first (of the entire table, this as far as I can tell also includes rows of horizontal lines), respectively. The advantages of using (b) over (a) are: - You have a split, friendly --- and probably highlighted --- view of what you're doing. - Multiple formulas can be inserted simply by breaking a line. In the case of (a), you would have to manually insert "::" for each new formula for a given cell or cell range. Note that inserting multiple "#+TBLFM:" in order to apply multiple formulas to the same table at once isn't right, only the first "#+TBLFM" is evaluated. ** Example --8<---------------cut here---------------start------------->8--- |----------+------------| | Average | Percentage | |----------+------------| | 3.01E+00 | -96.950355 | | 7.31E+00 | -92.593718 | |----------+------------| | 2.72E+01 | -72.441743 | | 4.09E+01 | -58.561297 | |----------+------------| | 6.80E+01 | -31.104357 | | 7.07E+01 | -28.368794 | |----------+------------| | 7.19E+01 | -27.152989 | | 9.87E+01 | | |----------+------------| #+TBLFM: @2$2..@>>$2=3Drelch(@>$1, $1) * 100 --8<---------------cut here---------------end--------------->8--- * If you want to calculate the percentage of the new value compared to the old value Such as: current / last_in_table Then use: $1 / @>$1 Instead of: relch(@>$1, $1) ** Example --8<---------------cut here---------------start------------->8--- |----------+------------| | Average | Percentage | |----------+------------| | 3.01E+00 | 3.0496454 | | 7.31E+00 | 7.4062817 | |----------+------------| | 2.72E+01 | 27.558257 | | 4.09E+01 | 41.438703 | |----------+------------| | 6.80E+01 | 68.895643 | | 7.07E+01 | 71.631206 | |----------+------------| | 7.19E+01 | 72.847011 | | 9.87E+01 | | |----------+------------| #+TBLFM: @2$2..@>>$2=3D($1 / @>$1) * 100 --8<---------------cut here---------------end--------------->8--- --=20 - [[https://libreplanet.org/wiki/User:Adfeno]] - Palestrante e consultor sobre /software/ livre (n=C3=A3o confundir com gratis). - "WhatsApp"? Ele n=C3=A3o =C3=A9 livre, por isso n=C3=A3o uso. Iguais a el= e prefiro GNU Ring, ou Tox. Quer outras formas de contato? Adicione o vCard que est=C3=A1 no endere=C3=A7o acima aos teus contatos. - Pretende me enviar arquivos .doc, .ppt, .cdr, ou .mp3? OK, eu aceito, mas n=C3=A3o repasso. Entrego apenas em formatos favor=C3=A1veis = ao /software/ livre. Favor entrar em contato em caso de d=C3=BAvida.