emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode@gnu.org
Subject: orgtables should taking into account empty cells when adding
Date: Mon, 13 Jun 2022 15:17:44 +0200	[thread overview]
Message-ID: <87tu8oem87.fsf@mat.ucm.es> (raw)

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	other threads:[~2022-06-13 13:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tu8oem87.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).