emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

orgtables should taking into account empty cells when adding


From: Uwe Brauer
Subject: orgtables should taking into account empty cells when adding
Date: Mon, 13 Jun 2022 15:17:44 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

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 

   




reply via email to

[Prev in Thread] Current Thread [Next in Thread]