* orgtables should taking into account empty cells when adding
@ 2022-06-13 13:17 Uwe Brauer
0 siblings, 0 replies; only message in thread
From: Uwe Brauer @ 2022-06-13 13:17 UTC (permalink / raw)
To: emacs-orgmode
Hi
Consider please
#+begin_src emacs-lisp :results silent :exports none
| Name | Theory | Matlab | Exercises | Result |
|-------+--------+--------+-----------+--------|
| User1 | 5 | 2 | 1 | 8 |
| User2 | | 2 | 1 | NP |
| User3 | 4 | 1 | | NP |
,#+TBLFM: $5=if(typeof(vsum($2..$4)) == 12 , string("NP"),vsum($2..$4)); E f-1
#+end_src
Each cell in a row that is empty results in the string NP, so far so good.
Now I want to achieve the same but only if cells in the second column are empty. So I thought
#+begin_src emacs-lisp :results silent :exports none
| Name | Theory | Matlab | Exercises | Result |
|-------+--------+--------+----------+-------|
| User1 | 5 | 2 | 1 | 8 |
| User2 | | 2 | 1 | NP |
| User3 | 4 | 1 | 0 | 5 |
#+TBLFM: $5=if("$2" == "nan", string("NP"),vsum($2..$4)); E f-1
#+end_src
That looks ok, however when say a cell in the third column is empty, the problem starts
because it results in
#+begin_src emacs-lisp :results silent :exports none
| Name | Theory | Matlab | Exercises | Result |
|-------+--------+--------+-----------+--------|
| User1 | 5 | 2 | 1 | 8 |
| User2 | | 2 | 1 | NP |
| User3 | 4 | 1 | | nan |
,#+TBLFM: $5=if("$2" == "nan", string("NP"),vsum($2..$4)); E f-1
#+end_src
Any idea how to solve this problem (I don't know how to have several ifs in such expression)
regards
Uwe Brauer
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-13 13:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-13 13:17 orgtables should taking into account empty cells when adding Uwe Brauer
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).