emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bruno Barbier <brubar.cs@gmail.com>
To: Jeff Trull <edaskel@att.net>, emacs-orgmode@gnu.org
Subject: Re: Formulas on table cells containing '$'
Date: Thu, 18 May 2023 20:55:17 +0200	[thread overview]
Message-ID: <64667497.7b0a0220.ca9cf.021c@mx.google.com> (raw)
In-Reply-To: <CAF_DUeFAqMNG39-nTz1wxBt5qLyQTyQtT-=mW1jiz-B91Q9B9A@mail.gmail.com>


Jeff Trull <edaskel@att.net> writes:

> While investigating an error executing a table formula I discovered that
> cells containing '$' cause column references to be executed even when no
> attempt is made to evaluate cell contents as code. Here's a simple example:
>

Confirmed.


org tries first to resolve all references, recursively.


   '(length '(@1$3..@I$3))

   { resolving @1$3..@I$3 into ("$200.00" "$1.13" "$301.22") }
  
=  '(length '("$200.00" "$1.13" "$301.22"))

   { resolving $200 into ...
  
ERROR: '$200' is an invalid reference.



It's probably not by designed, but, it's definitely a limitation of
the current implementation.


As a workaround, you could hide your reference in elisp and resolve it
manually using `org-table-get-range'. That way you can add/remove "$" as
needed.


For example:

     | 3/1/2023  | Deposit                | $200.00 |
     | 3/13/2023 | Interest               | $1.13   |
     | 4/1/2023  | Deposit                | $301.22 |
     |-----------+------------------------+---------|
     |           | Number of Transactions | 3       |
     |           | Total                  | $502.35 |
     #+TBLFM: @4$3='(length (org-table-get-range (concat "@" "1$" "3..@" "I$" "3")))
     #+TBLFM: @5$3='(format "$%.2f" (apply '+ (mapcar (lambda (x) (string-to-number (substring x 1))) (org-table-get-range (concat "@" "1$" "3..@" "I$" "3")))))




Bruno



      reply	other threads:[~2023-05-18 18:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAF_DUeFAqMNG39-nTz1wxBt5qLyQTyQtT-=mW1jiz-B91Q9B9A.ref@mail.gmail.com>
2023-05-15 21:47 ` Formulas on table cells containing '$' Jeff Trull
2023-05-18 18:55   ` Bruno Barbier [this message]

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=64667497.7b0a0220.ca9cf.021c@mx.google.com \
    --to=brubar.cs@gmail.com \
    --cc=edaskel@att.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).