emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <e.fraga@ucl.ac.uk>
To: Guido Van Hoecke <guivho@gmail.com>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Using constants in columns
Date: Fri, 16 Oct 2015 14:48:38 +0100	[thread overview]
Message-ID: <877fmmsz49.fsf@ucl.ac.uk> (raw)
In-Reply-To: CAEySM9HgqrYQha1s3DupmceLAvyvrqo8usRrHsdrOuftokvbaQ@mail.gmail.com

On Friday, 16 Oct 2015 at 14:39, Guido Van Hoecke wrote:
> Hi,
>
> Is there a way to use a constant directly in a table column?
> I need to have a table where one of the columns can have one out of three
> possible values and wanted to use constants for this.
> From the following minimal example it appears that constants are only
> possible in formulas, or am I missing something?
>
> #+CONSTANTS: vat=1.21
> | 12.34 | $vat | #ERROR | 14.9314 |
>
> #+TBLFM: $3=$1*$2::$4=$1*$vat
>
> Using the $vat constant directly from the content of column 3 produces an
> error, using it from a formula works fine.
>
> If this is the way it is, I'll have to write a formula for each row of the
> column, that'd be a real pitty...

Maybe not pretty but for a small number of alternatives, you could do:

#+begin_src org
  ,#+constants: vat=[1.15,1.21,1.40]
  | amount | vat1 | vat2 | vat3 |   total |
  |--------+------+------+------+---------|
  |  12.34 |    1 |    0 |    0 |  14.191 |
  |  56.78 |    0 |    1 |    0 | 68.7038 |
  ,#+TBLFM: $5=$1*vsum($2..$4*$vat)
#+end_src

alternatively, you could have an integer value in the VAT column and use
that to index the vector of VAT values?
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.50.2, Org release_8.3.2-161-gd2ac25

  reply	other threads:[~2015-10-16 13:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16 12:39 Using constants in columns Guido Van Hoecke
2015-10-16 13:48 ` Eric S Fraga [this message]
2015-10-16 14:38   ` Guido Van Hoecke
2015-10-16 14:59     ` Eric S Fraga
2015-10-17 11:47       ` Guido Van Hoecke
2015-10-17 18:00         ` Michael Brand
2015-10-17 20:27           ` Guido Van Hoecke
2015-10-19  6:12             ` Eric S Fraga
2015-10-19  7:13               ` Guido Van Hoecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877fmmsz49.fsf@ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=guivho@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).