I have an org file in which I lookup for some values in different tables. The problem is that in two of them, only the first row gets its value, while in the rest of the rows the value returned is nil
.
#+tblname: L1A
| | | Last Name | First Name | Alias | Sex |
| ! | no | ln | fn | alias | sex |
|---+----+-----------+------------+-------+-----|
| # | 1 | Doe | Eduard | Ed | |
| # | 2 | Foo | Samuel | Sam | 0 |
| # | 3 | Bar | Alexia | Ale | 1 |
| # | 4 | Lol | Nadya | Nadya | 1 |
|---+----+-----------+------------+-------+-----|
| * | | | | Men | 2 |
| * | | | | Women | 2 |
| * | | | | Total | 4 |
#+TBLFM: $2=@#-2 :: @>>>$2=string("") :: @>>$2=string("") :: @>$2=string("")
#+TBLFM: @>>>$4=string("") :: @>>$4=string("") :: @>$4=string("")
#+TBLFM: @>>>$5=string("Men") :: @>>$5=string("Women") :: @>$5=string("Total")
#+TBLFM: @>>>$6=vcount(map(<if(eq(#1,0),1,[])>, @I..@II)) :: @>>$6=vcount(map(<if(eq(#1,1),1,[])>, @I..@II)) :: @>$6=vcount(@I..@II)
#+tblname: E1Ap1
| | No. | Name | Total | Exm. | Prd. 1 | Prd. 2 | Prd. 3 | Prd. 4 | Prd. 5 | Prd. 6 | Prd. F |
| ! | no | almn | tot | ex | P1 | P2 | P3 | P4 | P5 | P6 | PF |
|---+-----+-------+-------+------+--------+--------+--------+--------+--------+--------+--------|
| # | 1 | Ed | 8 | 10 | 5 | 10 | | 5 | 10 | 5 | 10 |
| # | 2 | Sam | 7 | 7 | 8 | 8 | 5 | 4 | 9 | 5 | 5 |
| # | 3 | Ale | 8 | 8 | 9 | 7 | 6 | 9 | 8 | 7 | 6 |
| # | 4 | Nadya | 10 | 9 | 10 | 10 | 10 | 10 | 10 | 10 | 10 |
|---+-----+-------+-------+------+--------+--------+--------+--------+--------+--------+--------|
| | | | | | | | | | | | |
#+TBLFM: $2=@#-2 :: $4=round((vsum($P1..$PF)+1.0-1.0+($ex*3))/(vcount($P1..$PF)+3.0))
#+TBLFM: $3='(org-lookup-first $no '(remote(L1A, @I$no..@II$no)) '(remote(L1A, @I$alias..@II$alias))) ::
#+tblname: E1Ap2
| | No. | Nombre | Total | Exm. | Prd. 1 | Prd. 2 | Prd. 3 | Prd. 4 | Prd. 5 | Prd. 6 | Prd. F |
| ! | no | almn | tot | ex | P1 | P2 | P3 | P4 | P5 | P6 | PF |
|---+-----+--------+-------+------+--------+--------+--------+--------+--------+--------+--------|
| # | 1 | Ed | 7 | 5 | 6 | 7 | 8 | 9 | 10 | 5 | 6 |
| # | 2 | Sam | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 |
| # | 3 | Ale | 7 | 8 | 7 | 6 | 5 | 8 | 7 | 6 | 5 |
| # | 4 | Nadya | 9 | 9 | 9 | 9 | 9 | 9 | 9 | 9 | 10 |
|---+-----+--------+-------+------+--------+--------+--------+--------+--------+--------+--------|
| | | | | | | | | | | | |
#+TBLFM: $2=@#-2 :: $4=round((vsum($P1..$PF)+1.0-1.0+($ex*3))/(vcount($P1..$PF)+3.0))
#+TBLFM: $3='(org-lookup-first $no '(remote(L1A, @I$no..@II$no)) '(remote(L1A, @I$alias..@II$alias))) ::
#+tblname: E1A1
| | No. | Name | Fails | Pr1 | Pr2 | Pr3 | Pr4 | Pr5 | Ex | AP | PE | SUM | AVERAGE | GRADE | LEVEL | RISK |
| ! | no | al | in | p1 | p2 | p3 | p4 | p5 | ex | ap | pe | sum | prom | cal | lvl | R |
| / | < | > | <> | < | | | | > | < | > | | < | > | < | > | |
|---+-----+------+-------+-----+-----+-----+-----+-----+-----+-----+----+-----+---------+-------+-------+------|
| # | 1 | Ed | 1 | 8 | 7 | | | | | | | 8 | 1.1 | 5 | 1 | !! |
| # | 2 | Sam | 2 | nil | nil | | | | | | | 0 | 0 | 5 | 1 | !! |
|---+-----+------+-------+-----+-----+-----+-----+-----+-----+-----+----+-----+---------+-------+-------+------|
| | | | 3 | 8 | 0 | 0 | 0 | 0 | 0 | 0 | | 8 | 1.1 | 10 | 2 | |
| | | | 1.5 | 3 | 0/0 | 0/0 | 0/0 | 0/0 | 0/0 | 0/0 | | 4 | 0.6 | 12.5 | 2.5 | |
#+TBLFM: $3='(org-lookup-first $no '(remote(L1A, @I$no..@II$no)) '(remote(L1A, @I$alias..@II$alias))) ::
#+TBLFM: $5='(org-lookup-first $no '(remote(E1Ap1,@I$no@II$no)) '(remote(E1Ap1, @I$tot..@II$tot))) :: $6='(org-lookup-first $no '(remote(E1Ap2,@I$no@II$no)) '(remote(E1Ap2, @I$tot..@II$tot)))
#+TBLNAME: E1A
| | No. | I1 | I2 | I3 | IT | P1 | R1 | P2 | R2 | P3 | R3 | SUM | GRADE | LEVEL | RISK |
| / | <> | < | | | > | < | > | < | > | < | > | < | | > | |
|---+-----+-----+----+----+-----+-----+----+----+----+----+----+-----+-------+-------+------|
| # | 1 | 1 | | | 1 | 5 | 6 | 7 | | 6 | | 19 | 6.3 | 2 | |
| # | 2 | nil | | | nil | 5 | | 7 | | 6 | | 18 | 6.0 | 2 | |
| # | 3 | nil | | | nil | nil | 6 | 7 | | 6 | | 19 | 6.3 | 2 | |
| # | 4 | nil | | | nil | nil | | 7 | | 5 | | 17 | 5.7 | 1 | 6.15 |
|---+-----+-----+----+----+-----+-----+----+----+----+----+----+-----+-------+-------+------|
| | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | |
#+tblfm: $3='(org-lookup-first $2 '(remote(E1A1, @I$no..@II$no)) '(remote(E1A1, @I$in@II$in))) :: $7='(org-lookup-first $2 '(remote(E1A1, @I$no..@II$no)) '(remote(E1A1, @I$cal..@II$cal)))
When I execute the formulas for lookup in tables E1A1
and E1A
, the first row gets the correct value, but the others get nil
.
Here is the debug output for the first nil
:
Substitution history of formula
Orig: '(org-lookup-first $no '(remote(E1Ap1,@I$no@II$no)) '(remote(E1Ap1, @I$tot..@II$tot)))
$xyz-> '(org-lookup-first $2 '(remote(E1Ap1,@I$2@II$2)) '(remote(E1Ap1, @I$tot..@II$tot)))
@r$c-> '(org-lookup-first $2 '(#("1" 0 1 (fontified t face org-table))) '(#("8" 0 1 (fontified t face org-table)) #("7" 0 1 (fontified t face org-table)) #("8" 0 1 (fontified t face org-table)) #("10" 0 2 (fontified t face org-table))))
$1-> '(org-lookup-first "2" '(#("1" 0 1 (fontified t face org-table))) '(#("8" 0 1 (fontified t face org-table)) #("7" 0 1 (fontified t face org-table)) #("8" 0 1 (fontified t face org-table)) #("10" 0 2 (fontified t face org-table))))
Result: nil
Format: NONE
Final: nil
When I try with simpler examples (even with the same number of tables and references), all goes wright.
What I am doing wrong? How can I fix this?
I'm using emacs 26.1 with org-mode
9.2.1. on Debian GNU/Linux 10 (buster).