emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 2 questions on tables
@ 2013-07-15  6:47 Andreas Leha
  2013-07-15  8:41 ` Michael Brand
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Leha @ 2013-07-15  6:47 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I have two questions concerning tables in orgmode:

1. What is the best way to handle missing values?
   I have the problem, that missing values ("") are treated as "0" when they
   appear in a formula.
   Entering ("nil") instead helps a bit, but does not propagate,
   i.e. nil + 1 results in 0.
   Can I do better?
2. What is the best way to drop a column while preserving the number of
   digits displayed?
   I use a simple code block to drop the columns.  But I do not see how
   to prevent orgmode from dropping trailing 0s

Here is an example demonstrating both questions:
--8<---------------cut here---------------start------------->8---
#+TITLE: Drop columns

* Create Some Table with a Missing Value
#+name: mytable
| Item      | Price ($) | Price ($+1) |
|-----------+-----------+-------------|
| Apple     |     10.55 |       11.55 |
| Tomato II |       nil |        0.00 |
| Tomato    |           |        1.00 |
| Pear      |      3.00 |        4.00 |
| Monkey    |    100.55 |      101.55 |
|-----------+-----------+-------------|
| Sum       |     10.55 |      118.10 |
#+TBLFM: $3=$2+1;%.2f::@7$2=vsum(@I..@II);%.2f::@7$3=vsum(@I..@II);%.2f


* Drop a Column
#+name: mysmalltable
#+begin_src emacs-lisp :var input=mytable[,0:1] :exports results
  input
#+end_src

#+results: mysmalltable
| Item   | Price ($) |
|--------+-----------|
| Apple  |     10.55 |
| Tomato |           |
| Pear   |       3.0 |
| Monkey |    100.55 |
--8<---------------cut here---------------end--------------->8---

Regards,
Andreas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 2 questions on tables
  2013-07-15  6:47 2 questions on tables Andreas Leha
@ 2013-07-15  8:41 ` Michael Brand
  2013-07-15  9:12   ` Andreas Leha
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Brand @ 2013-07-15  8:41 UTC (permalink / raw)
  To: Andreas Leha; +Cc: Org Mode

Hi Andreas

On Mon, Jul 15, 2013 at 8:47 AM, Andreas Leha
<andreas.leha@med.uni-goettingen.de> wrote:
> I have two questions concerning tables in orgmode:

I try to answer your first question:

> 1. What is the best way to handle missing values?
>    I have the problem, that missing values ("") are treated as "0" when they
>    appear in a formula.
>    Entering ("nil") instead helps a bit, but does not propagate,
>    i.e. nil + 1 results in 0.
>    Can I do better?

Is this what you are looking for?:

| Tomato |      |      |
| Pear   | 3.00 | 6.00 |
#+TBLFM: $3 = if("$2" == "nan", string(""), 2 * $2 +.0); E f-2

For "E" see
http://orgmode.org/org.html#Formula-syntax-for-Calc
and for "+.0; f-2" see
http://orgmode.org/worg/org-faq.html#table-float-fraction

Michael

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 2 questions on tables
  2013-07-15  8:41 ` Michael Brand
@ 2013-07-15  9:12   ` Andreas Leha
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Leha @ 2013-07-15  9:12 UTC (permalink / raw)
  To: emacs-orgmode

Hi Michael,

Michael Brand <michael.ch.brand@gmail.com> writes:

> Hi Andreas
>
> On Mon, Jul 15, 2013 at 8:47 AM, Andreas Leha
> <andreas.leha@med.uni-goettingen.de> wrote:
>> I have two questions concerning tables in orgmode:
>
> I try to answer your first question:
>
>> 1. What is the best way to handle missing values?
>>    I have the problem, that missing values ("") are treated as "0" when they
>>    appear in a formula.
>>    Entering ("nil") instead helps a bit, but does not propagate,
>>    i.e. nil + 1 results in 0.
>>    Can I do better?
>
> Is this what you are looking for?:
>
> | Tomato |      |      |
> | Pear   | 3.00 | 6.00 |
> #+TBLFM: $3 = if("$2" == "nan", string(""), 2 * $2 +.0); E f-2
>
> For "E" see
> http://orgmode.org/org.html#Formula-syntax-for-Calc
> and for "+.0; f-2" see
> http://orgmode.org/worg/org-faq.html#table-float-fraction
>
> Michael

thanks a lot!  All three comments (the if() statement, the "E" and the
"f-2") of yours are extremely helpful.

Question one solved.

Cheers,
Andreas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-15  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-15  6:47 2 questions on tables Andreas Leha
2013-07-15  8:41 ` Michael Brand
2013-07-15  9:12   ` Andreas Leha

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).