[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Calculating percentage
From: |
Adonay Felipe Nogueira |
Subject: |
Re: [O] Calculating percentage |
Date: |
Sat, 15 Jul 2017 11:56:52 -0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
* 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=relch(@>$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=relch(@>$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=relch(@>$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=($1 / @>$1) * 100
--8<---------------cut here---------------end--------------->8---
--
- [[https://libreplanet.org/wiki/User:Adfeno]]
- Palestrante e consultor sobre /software/ livre (não confundir com
gratis).
- "WhatsApp"? Ele não é livre, por isso não uso. Iguais a ele prefiro
GNU Ring, ou Tox. Quer outras formas de contato? Adicione o vCard
que está no endereço acima aos teus contatos.
- Pretende me enviar arquivos .doc, .ppt, .cdr, ou .mp3? OK, eu
aceito, mas não repasso. Entrego apenas em formatos favoráveis ao
/software/ livre. Favor entrar em contato em caso de dúvida.