* TBLFM and a remote table lookup on two columns
[not found] <1631286440.844682.1529646045252.ref@mail.yahoo.com>
@ 2018-06-22 5:40 ` Brad Knotwell
2018-06-22 6:33 ` Thierry Banel
0 siblings, 1 reply; 2+ messages in thread
From: Brad Knotwell @ 2018-06-22 5:40 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1801 bytes --]
Good day all--
I've been using TBLFM and orgmode-lookup-first to conditionally update a table. It works great but I've run into something that has stumped me. Imagine I have a table like the following:
#+name: lookup_geo--------+-----+---|| T | L | Y ||--------+-----+---|| WEII | SEA | 3 || WEIII | SEA | 4 || WEIII | SJC | 3 ||--------+-----+---|
|--------+-----+-------+---------------------------------|| T | L | Count | Cost (Count * matching Y above) ||--------+-----+-------+---------------------------------|| WEIII | SJC | 3 | #ERROR || WEIII | SEA | 5 | #ERROR ||--------+-----+-------+---------------------------------|
# the TBLFM syntax below doesn't work, it's just how I would've guessed it might.
#+TBLFM: $4=`(org-lookup-first '($1 $2) '((remote(lookup_geo,@2$1..@>$1)) (remote(lookup_geo,@2$2..@>$2))) '(remote(lookup_geo,@2$3..@>$3))))
As far as I can tell, orgmode-lookup-first allows me to match the first(T) or second(L) column but it's entirely unclear how to match both. While I could workaround this with multiple tables (e.g. a separate named table/location and then have code dynamically generate the appropriate table name), a separate source block or a single key composed of two parts (e.g "WEII - SEA"; this is my current favorite workaround), I wondered if there might be a better solution.
I also considered whether it would make sense for the predicate to be given access to the entire matched row so something like the following could work:
'lambda (row) (and (= $1 (car row)) (= $2 (cadr row))))
Anyhow, is there a better way to do this beyond creating a single column that combines what was two columns?
Thx.
--Brad
[-- Attachment #2: Type: text/html, Size: 3087 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: TBLFM and a remote table lookup on two columns
2018-06-22 5:40 ` TBLFM and a remote table lookup on two columns Brad Knotwell
@ 2018-06-22 6:33 ` Thierry Banel
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Banel @ 2018-06-22 6:33 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/html, Size: 7136 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-22 6:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1631286440.844682.1529646045252.ref@mail.yahoo.com>
2018-06-22 5:40 ` TBLFM and a remote table lookup on two columns Brad Knotwell
2018-06-22 6:33 ` Thierry Banel
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).