From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id AIXPAApJ82V2MwEAe85BDQ:P1 (envelope-from ) for ; Thu, 14 Mar 2024 19:59:22 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id AIXPAApJ82V2MwEAe85BDQ (envelope-from ) for ; Thu, 14 Mar 2024 19:59:22 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Cj2PXAGO; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1710442761; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=g0LvYkplki6SMlo/lWA8zy1/Q5jUKTpY5o6dornkDcQ=; b=L/IFeKbqNY1z3MAkJkHCBBI6dDZUKX9xvUUXrK70j4xAUiyH3stjjG1InGj+by8qMR7FFw gn3fEutv8wZDwudY6EEdlEmYJkgEtxT/No7sRxaDJdtcjelYSuDx6YejFa69W69gg3NJqL mVOQ+/te3cUhq3KKH9lOhrUDBJtJ7HOzHyaqv0geMhdQMua46jaTs4S4jWX8Tn1SCa46IY 5ewTyK5MD8Oje95FSMO/Q3XvEgWVnpgaUEkIMwgq7wmAVnhtoZqc7tdUkvzG6uIeqFtwI3 Es1kBW2H2x3SbMAUmHHTl6GqweXNoLbaoSeDd3XVce6mNj3OhsIKdvI6U6/bdQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1710442761; a=rsa-sha256; cv=none; b=EyK/aIenFUUfmf5y5hTzhzxkfWqL37cIMgDaMM/18OpN/75pw22vBzp3Cq5kdqm1yRwbLp GlNKF6nNLZehRAP2iuNhcHU9/F2EL5JmhIrOvnZRO6LYgJkf4soJbXTbqooIyi1q2GLrDj gLXMSo2q6XNCkFPaTSxoehhBhb2TinFwnkZNXm8W88njhQhGGCeic9+bHt86EbHuJr3U6e cK0YUFDffdqK1hTU/WzwQx2N36bLtGtHzvQPZKcMNiCQCHbPN0NJHF8yQ9u8MgFT+y9SV9 7/l88Ybtb3atxM0pJv2CHr9j8Ir6/xd4l3behRWcblPHVoDS8ZG9EHmKtu58Jw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Cj2PXAGO; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net 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 E1B363FD58 for ; Thu, 14 Mar 2024 19:59:21 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkqIC-00008g-PV; Thu, 14 Mar 2024 14:59:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkqI4-00008H-BV for emacs-orgmode@gnu.org; Thu, 14 Mar 2024 14:58:58 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkqI1-0000ly-I3 for emacs-orgmode@gnu.org; Thu, 14 Mar 2024 14:58:55 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id ACDC5240104 for ; Thu, 14 Mar 2024 19:58:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1710442730; bh=jHRk3wbhLvybNUUz57fl16rVcFw7yKFAYu1R79YDGRk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=Cj2PXAGOhDeFEYCQVU4DjGprrcDZkJ2qyomgw/jg3RaOZ0PPdzyiQWWKeagj/NW4H XpWXDbPDdybALCH3CY0OfN4Y2mr1l2UsNjBaFTH7lIK5dvRNhcKjb+Cc91UG88HCWl gGP8JCkdYDHEFzr6eMLo0pPHKSx9rsRFMtvyui3ppsU+hJ5tC/q9qDJTFSVsFc0rxN gASqUDOr5cumh2oqctcFAYBZ/PnxJO3yxJDJyq26dQ2eqKCgkjZT+RVXTGQ1GGiQ47 baZMpg3+r/b2cxVAUnIPRYqvusH9sP5NlCYOK9QjngjdarWl5K6j06VgcOREXxEyG9 ICYQoDZAHrviQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Twc9P6WH7z6txV; Thu, 14 Mar 2024 19:58:49 +0100 (CET) From: Ihor Radchenko To: Wu Ming Cc: emacs-orgmode@gnu.org Subject: Re: Table column formula with remote reference In-Reply-To: <196ADD6A-7FD8-4002-8C30-BFCFE71070BB@icloud.com> References: <1F92C461-F43D-48F4-B153-1AD7B308D377@icloud.com> <87zfv3bj8d.fsf@localhost> <86F6BD74-10F6-4796-B1A5-23B4FB425336@icloud.com> <8734suxr7b.fsf@localhost> <196ADD6A-7FD8-4002-8C30-BFCFE71070BB@icloud.com> Date: Thu, 14 Mar 2024 21:58:32 +0000 Message-ID: <87sf0sh3w7.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -5.49 X-Spam-Score: -5.49 X-Migadu-Queue-Id: E1B363FD58 X-Migadu-Scanner: mx11.migadu.com X-TUID: V55SI4aJSt8x Wu Ming writes: >> See "Remote references" subsection. It explains that in >> remote(NAME,REF), REF is inside the remote table. Relative and current >> column/row is ambiguous there. >>=20 >> In contrast, @# and $# are special - they are replaced before >> remote(...) is processed. > ... > I have some trouble at understanding your answer. Do you mean @# refers a= row on the table where the formula belongs and @0 refers a row on the remo= te table? Was tempted to describe the former as =E2=80=9Ccurrent=E2=80=9D b= ut remote table is also current when accessed. A better noun may be needed. Let me elaborate. When Org mode sees something like #+TBLFML: $1 =3D $2 + remote(A,@@#$1)=20 1. it goes to every cell in column 1 and remembers current column and row numbers (original cell) 2. In the right side of the formula $2 + remote(A,@@#$1), Org replaces all the instances of @# and $# with current column and row. So, when we are calculating the value for @1$1, we get $2 + remote(A,@1$1) 3. Org moves to table A and replaces remote(A,@1$1) with cell contents of @1$1 inside table A. At this point, it is not allowed to have relative references like $1 or $-1, because "current" column and row are set inside remote table A - the original cell coordinates are not available. 4. Org goes back to the original table, takes the updated formula $2 + , and replaces relative reference $2 according to the current column - with the value stored in @1$2 column 5. Org passes the resulting expression + to GNU cal and assigns the result as the value of the current cell @1$1. 6. Repeat for @2..$1 cells. As you can see, @# and $# substitution always uses local cell coordinates. Any other relative reference is not allowed inside remote(...). > This made me worry about reliability of simple biz calculations I am tryi= ng on Org spreadsheet for the first time. Please advise. Formula debugger is really helpful to understand the process. > Finally I moved columns but now column numbers in formulas don=E2=80=99t = relate to column order on display. How to understand which column formula a= ffect which column? Normally, if you use org-table-* commands, the formulas get updated when you move the columns. To make things more readable, you can also assign names to columns: | ! | | P1 | P2 | P3 | Tot | | | | Maximum | 10 | 15 | 25 | 50 | 10.0 | Then, you can write $P1 =3D ... instead of $3 =3D ... See "3.5.10 Advanced features" section of the manual. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at