Follow this question
I have error when I look for the missing value :
* t1
#+tblname: t1
|----+---|
| P1 | 1 |
| P2 | 2 |
| P3 | 3 |
|----+---+
* t2
#+tblname: t2
|----+---|
| P1 | 10 |
| P2 | 20 |
| P3 | 30 |
|----+---+
* t3
#+tblname: t3
|----+-----|
| P1 | 100 |
| P2 | 200 |
| P3 | 300 |
| P4 | |
|----+-----|
* Total
| Nom | |
|-----+--------|
| P1 | 111 |
| P2 | 222 |
| P3 | 333 |
| P4 | #ERROR |
#+TBLFM: $2='(my/total-for $1)
* Code
#+begin_src elisp
(defun my/list-of-tables ()
(org-element-map (org-element-parse-buffer)
'table
(lambda (tbl) (plist-get (cadr tbl) :name))))
#+end_src
#+RESULTS:
: my/list-of-tables
#+begin_src elisp :results verbatim
(my/list-of-tables)
#+end_src
#+RESULTS:
: ("t1")
#+begin_src elisp
(defun my/total-for (name)
(let ((tables (my/list-of-tables))
(sum 0))
(dolist (tab tables)
(setq sum (+ sum (string-to-number
(org-lookup-first name
(org-table-get-remote-range tab "@I$1..@II$1")
(org-table-get-remote-range tab "@I$2..@II$2"))))))
(number-to-string sum)))
#+end_src
#+RESULTS:
: my/total-for