emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: "Daniel E. Doherty" <ded@ddoherty.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: Allow Currency Symbols and Grouping Commas in Table Numbers
Date: Fri, 27 May 2022 22:49:58 +0800	[thread overview]
Message-ID: <87ee0f58tl.fsf@localhost> (raw)
In-Reply-To: <87y1ynul7o.fsf@ddoherty.net>

"Daniel E. Doherty" <ded@ddoherty.net> writes:

> | Description  | Amount     |
> |--------------+------------|
> | Mortage      | 125,000.26 |
> | Credit Cards | 6,325.00   |
> | Auto Loan    | 14,853.00  |
> |--------------+------------|
> | Total        | 1323.26    |
> #+TBLFM: @5$2=vsum(@I..@II)
>
> Note that the total is wrong.

Well. This is also a caveat from calc, unfortunately.

7.7.2 Grouping Digits
   Please note that grouped numbers will not generally be parsed
correctly if re-read in textual form, say by the use of ‘C-x * y’ and
‘C-x * g’.  (*Note Kill and Yank::, for details on these commands.)  One
exception is the ‘\,’ separator, which doesn’t interfere with parsing
because it is ignored by TeX language mode.

So, you can instead do

| Description  | Amount      |
|--------------+-------------|
| Mortage      | 125\,000.26 |
| Credit Cards | 6\,325.00   |
| Auto Loan    | 14\,853.00  |
|--------------+-------------|
| Total        | 146178.26   |
#+TBLFM: @5$2=vsum(@I..@II)

Or with

#+begin_SRC emacs-lisp
(setq org-calc-default-modes
      '( calc-internal-prec 12
	 calc-float-format  (float 8)
	 calc-angle-mode    deg
	 calc-prefer-frac   nil
	 calc-symbolic-mode nil
	 calc-language latex ;; <--- this is new compared to default, enable latex symbols
	 calc-group-digits t ;; <--- group digits in the results
	 calc-group-char "\\,"
	 calc-date-format (YYYY "-" MM "-" DD " " Www (" " hh ":" mm))
	 calc-display-working-message t))
#+end_SRC

| Description  | Amount      |
|--------------+-------------|
| Mortage      | 125\,000.26 |
| Credit Cards | 6\,325.00   |
| Auto Loan    | 14\,853.00  |
|--------------+-------------|
| Total        | 146\,178.26 |
#+TBLFM: @5$2=vsum(@I..@II)

> | Description  | Amount                     |
> |--------------+----------------------------|
> | Mortage      | \dollar 125000.26          |
> | Credit Cards | 6325.00                    |
> | Auto Loan    | 14853.00                   |
> |--------------+----------------------------|
> | Total        | 125000.26 \dollar + 21178. |
> #+TBLFM: @5$2=vsum(@I..@II)
>
> Total is still wrong.

You need 

| Description  | Amount                     |
|--------------+----------------------------|
| Mortage      | \dollar 125000.26          |
| Credit Cards | \dollar 6325.00            |
| Auto Loan    | \dollar 14853.00           |
|--------------+----------------------------|
| Total        | 146178.26 \dollar          |
#+TBLFM: @5$2=vsum(@I..@II)


Best,
Ihor


  reply	other threads:[~2022-05-27 14:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26 19:40 Allow Currency Symbols and Grouping Commas in Table Numbers Daniel E. Doherty
2022-05-27  8:22 ` Ihor Radchenko
2022-05-27 11:00   ` Eric S Fraga
2022-05-27 11:17     ` Ihor Radchenko
2022-05-27 12:02       ` Eric S Fraga
2022-05-27 13:49   ` Daniel E. Doherty
2022-05-27 14:49     ` Ihor Radchenko [this message]
2022-05-31 14:19       ` Daniel E. Doherty
2022-06-02  4:57         ` Ihor Radchenko
2022-06-03 20:37           ` Daniel E. Doherty

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=87ee0f58tl.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=ded@ddoherty.net \
    --cc=emacs-orgmode@gnu.org \
    /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).