emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Brand <michael.ch.brand@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Cc: Bob Newell <bobnewell@bobnewell.net>,
	Thorsten Jolitz <tjolitz@googlemail.com>,
	Nick Dokos <nicholas.dokos@hp.com>
Subject: Re: Distinguish between blank and zero in org-mode spreadsheet
Date: Tue, 11 Dec 2012 16:14:48 +0100	[thread overview]
Message-ID: <CALn3zogzkfTSx__QgL7SadM39nmXiT9fuMUVQki4DSOsWP8UgQ@mail.gmail.com> (raw)
In-Reply-To: <5596.1355206238@alphaville>

Hi all

I would also like if some interest could be spent in this (see subject)
area. Let me give some examples as an overview, grouped as “check if
empty”, “range” and “single fields”. The first is the only one
directly related to the OP question. But the others still match the
subject perfectly. Most of the examples include my suggestions of how
I expect them to work, hopefully ending up in a regression test at
some time.

- check if empty: $3 results should be as $4 or even better as $5 if
  not too difficult. I don’t know of any Calc formula that does this
  currently, so I took the one I would prefer to use.
  | 1 |    0 | 1 =  && 0 =  ?  : 1 + 0       |        1 |      1 |
  | 1 |      | 1 =  && 0 =  ?  : 1 + 0       |          |        |
  | 1 | text | 1 =  && text =  ?  : 1 + text | 1 + text | #ERROR |
  #+TBLFM: $3 = if($1 = string("") && $2 = string(""), string(""), $1 + $2)

- input from range as vsum($1..$2):
  1) empty -> 0, non-number -> 0: The format specifier is documented
     as “N: interpret all fields as numbers, use 0 for non-numbers”.
     Works as expected.
     | 1 |    0 | 1 |
     | 1 |      | 1 |
     | 1 | text | 1 |
     #+TBLFM: $3 = vsum($1..$2); N

  2) empty -> 0, keep other non-numbers: Without “N” I would prefer $3
     results to be as $4 if not too difficult.
     | 1 |    0 |        1 |      1 |
     | 1 |      |        1 |      1 |
     | 1 | text | 1 + text | #ERROR |
     #+TBLFM: $3 = vsum($1..$2)

  3) numbers only: The format specifier is documented as “E: keep
     empty fields in ranges”. I would prefer $3 results to be as $4 if
     not too difficult.
     | 1 |    0 | 1        | 1      |
     | 1 |      | #ERROR   | #ERROR |
     | 1 | text | 1 + text | #ERROR |
     #+TBLFM: $3 = vsum($1..$2); E

- input from single fields as $1 + $2:
  1) empty -> 0, non-number -> 0: Works as expected.
     | 1 |    0 | 1 |
     | 1 |      | 1 |
     | 1 | text | 1 |
     #+TBLFM: $3 = $1 + $2; N

  2) empty -> 0, keep other non-numbers: Without “N” I would prefer $3
     results to be as $4 if not too difficult.
     | 1 |    0 |        1 |      1 |
     | 1 |      |        1 |      1 |
     | 1 | text | 1 + text | #ERROR |
     #+TBLFM: $3 = $1 + $2

  3) numbers only: I suggest to extend the currently documented
     “E: keep empty fields in ranges” to “E: keep empty fields” or
     clearer “E: keep empty fields as non-numbers” and then would
     prefer $3 results to be as $4 or if not too difficult even better
     as $5.
     | 1 |    0 |        1 |        1 | 1      |
     | 1 |      |        1 |          | #ERROR |
     | 1 | text | 1 + text | 1 + text | #ERROR |
     #+TBLFM: $3 = $1 + $2; E

Minor issue: I wonder what the entry “vmean($2..$7);EN : Same, but
treat empty fields as 0” in the manual means or is useful for.

Michael

  reply	other threads:[~2012-12-11 15:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-10 22:32 Distinguish between blank and zero in org-mode spreadsheet Bob Newell
2012-12-10 22:57 ` Thorsten Jolitz
2012-12-11  4:50   ` Bob Newell
2012-12-11  6:10     ` Nick Dokos
2012-12-11 15:14       ` Michael Brand [this message]
2012-12-15  9:15         ` Michael Brand
2012-12-15  9:23           ` Bastien
2012-12-28 14:10             ` Michael Brand
2012-12-29 13:39               ` Bastien

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=CALn3zogzkfTSx__QgL7SadM39nmXiT9fuMUVQki4DSOsWP8UgQ@mail.gmail.com \
    --to=michael.ch.brand@gmail.com \
    --cc=bobnewell@bobnewell.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=nicholas.dokos@hp.com \
    --cc=tjolitz@googlemail.com \
    /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).