From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 1R8iLCEThF+zfQAA0tVLHw (envelope-from ) for ; Mon, 12 Oct 2020 08:26:09 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id CPOHJyEThF+RdgAA1q6Kng (envelope-from ) for ; Mon, 12 Oct 2020 08:26:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D653494060E for ; Mon, 12 Oct 2020 08:26:08 +0000 (UTC) Received: from localhost ([::1]:40388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kRt9j-0006oQ-At for larch@yhetil.org; Mon, 12 Oct 2020 04:26:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRt9N-0006oG-Vu for emacs-orgmode@gnu.org; Mon, 12 Oct 2020 04:25:46 -0400 Received: from mailer-211-161.hitrost.net ([91.185.211.161]:13383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kRt9L-00072F-Gp for emacs-orgmode@gnu.org; Mon, 12 Oct 2020 04:25:45 -0400 Received: from lk.84.20.244.182.dc.cable.static.lj-kabel.net ([84.20.244.182] helo=Tauriel) by b1.hitrost.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1kRt9A-007KMq-Dk; Mon, 12 Oct 2020 10:25:32 +0200 References: <3444a52f-36a7-6e9d-46b9-272dddc7a3ef@grinta.net> <87wo0jttxz.fsf@christianmoe.com> User-agent: mu4e 0.9.19; emacs 25.3.2 From: Christian Moe To: Daniele Nicolodi Subject: Re: org-tables with monetary amounts In-reply-to: Date: Mon, 12 Oct 2020 10:22:53 +0200 Message-ID: <87sgaj26qq.fsf@christianmoe.com> MIME-Version: 1.0 Content-Type: text/plain X-GeoIP: Country [IP], SI [84.20.244.182] X-Antivirus-Scanner: Clean mail though you should still use an Antivirus Received-SPF: pass client-ip=91.185.211.161; envelope-from=mail@christianmoe.com; helo=mailer-211-161.hitrost.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/12 04:25:33 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, LOTS_OF_MONEY=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.01 X-TUID: oIIxWuEJ1rOD Hi, Daniele, Good that it's working for you. I'll try to explain the unclear parts. Daniele Nicolodi writes: > On 24/09/2020 11:17, Christian Moe wrote: > >> Now, with the Calc command to simplify units, you can add dollars to >> euros and get the result in whichever currency comes first in the >> algebraic expression >> >> | 3 USD | 4 EUR | 6.58 EUR | >> #+tblfm: $3=usimplify($2+$1) >> >> | 3 USD | 4 EUR | 7.6511628 USD | >> #+tblfm: $3=usimplify($1+$2) > > Having to explicitly use usimplify() is a bit too verbose. It would be > ideal if this could be somehow be implicit. Yes, or at least with a less obtrusive syntax, like a mode flag, something like $3=$2+$1;u (here using "u" for "units" -- unfortunately, capital "U" is already taken) >> I don't use this functionality, so I don't have answers to all the >> questions you'll now have -- including how to get the desired precision >> without lopping off the currency unit in the last example! > > Having the desired fixed precision is quite important for this to be > useful. In y recent tests I had to drop the units (currencies) to > achieve this. It would be nice to find a way to avoid it. [...] >> Apart from `usimplify', most Calc functions on units appear (?) to be >> missing corresponding algebraic versions that you can use in Calc >> expressions in Org tables, which limits the usefulness. I may be missing something, but it looks like handy Calc commands like simple unit conversion currently can't be used in an Org spreadsheet, making Calc units less useful in the spreadsheet. And that this is due to a lacuna in Calc, not in Org. When using Calc directly, there are two ways to enter calculations. The default is reverse Polish notation on the stack (like an old HP calculator), with various keys bound to all the available commands. The alternative is algebraic notation. For example, the command for square root is `calc-sqrt', entered with the `Q' key. To get the square root of two, you would enter `2 Q' or `2 RET Q'. The corresponding function to use in algebraic notation is `sqrt'. To use it, you would press apostrophe for algebraic notation, and enter `sqrt(2) RET'. But while all Calc commands have keys assigned, it seems not all have corresponding algebraic notation (?). The Calc manual says that the command `u s' (`calc-simplify-units') has the algebraic expression `usimplify'. But it does not list such expressions for other handy Calc commands, like the `u c' (`calc-convert-units') command, the `u r' (`calc-remove-units') command or the `u x' (`calc-extract-units') command. The Org spreadsheet can also use Lisp formulas, so I've tried to use calc-simplify-units directly, but this leads to #ERROR. >> Org tables don't seem to have any specific formula syntax for leveraging >> Calc unit operations apart from what happens to work out of the >> box. This might be an area for improvement, though I'm not sure what to >> ask for. I think I was thinking about adding mode flags for unit computations, like in the imagined example above (`$3=$2+$1;u'), similar to what has been done for duration computations. See the manual, 3.5.2 Formula syntax for Calc. Might be useful, but I'm not sure how to specify a request. > I don't understand what you mean in the two paragraphs above. Can you > please clarify, maybe with examples? Hope this helps. Yours, Christian