emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* empty cells in columns should be left emtpy when manipulating columns
@ 2017-06-22  7:25 Uwe Brauer
  2017-06-22  7:34 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Brauer @ 2017-06-22  7:25 UTC (permalink / raw)
  To: emacs-orgmode


Please consider this

| 3.25 | 0.4875 |
|      |     0. |
| 2.25 | 0.3375 |
#+TBLFM: $2=$1*0.15

How can I avoid the entry 0.  ?

I could insert **

Giving

| 3.25 |  0.4875 |
|   ** |  #ERROR |
| 2.25 |  0.3375 |
#+TBLFM: $2=$1*0.15

But this is cumbersome, any other possibilities?

Thanks

Uwe Brauer 

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

* Re: empty cells in columns should be left emtpy when manipulating columns
  2017-06-22  7:25 empty cells in columns should be left emtpy when manipulating columns Uwe Brauer
@ 2017-06-22  7:34 ` Nicolas Goaziou
  2017-06-22  7:56   ` Uwe Brauer
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2017-06-22  7:34 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Uwe Brauer <oub@mat.ucm.es> writes:

> Please consider this
>
> | 3.25 | 0.4875 |
> |      |     0. |
> | 2.25 | 0.3375 |
>
> #+TBLFM: $2=$1*0.15
>
> How can I avoid the entry 0.  ?

One possibility:

    | 3.25 | 0.4875 |
    |      |        |
    | 2.25 | 0.3375 |
    #+TBLFM: $2=if("$1" == "nan", string(""), $1*0.15);E


Regards,

-- 
Nicolas Goaziou

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

* Re: empty cells in columns should be left emtpy when manipulating columns
  2017-06-22  7:34 ` Nicolas Goaziou
@ 2017-06-22  7:56   ` Uwe Brauer
  2017-06-23 16:20     ` Michael Brand
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Brauer @ 2017-06-22  7:56 UTC (permalink / raw)
  To: emacs-orgmode


   > Hello,
   > Uwe Brauer <oub@mat.ucm.es> writes:


   > One possibility:

   >     | 3.25 | 0.4875 |
   >     |      |        |
   >     | 2.25 | 0.3375 |

   >     #+TBLFM: $2=if("$1" == "nan", string(""), $1*0.15);E

Great but how can I round?

#+TBLFM: $2=if("$1" == "nan", string(""), $1*0.15;%.1f);E

And friends did not work any more

| 3.25 | 0.5) |
|      | 0.0) |
#+TBLFM: $2=if("$1" == "nan", string(""), $1*0.15;%.1f);E

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

* Re: empty cells in columns should be left emtpy when manipulating columns
  2017-06-22  7:56   ` Uwe Brauer
@ 2017-06-23 16:20     ` Michael Brand
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Brand @ 2017-06-23 16:20 UTC (permalink / raw)
  To: Org Mode

Hi Uwe

On Thu, Jun 22, 2017 at 9:56 AM, Uwe Brauer <oub@mat.ucm.es> wrote:

> #+TBLFM: $2=if("$1" == "nan", string(""), $1*0.15;%.1f);E
>
> And friends did not work any more
>
> | 3.25 | 0.5) |
> |      | 0.0) |
> #+TBLFM: $2=if("$1" == "nan", string(""), $1*0.15;%.1f);E

This is invalid syntax, what you meant would be:

| 3.25 | 0.5 |
|      | 0.0 |
#+TBLFM: $2=if("$1" == "nan", string(""), $1*0.15);E %.1f

To preserve empty columns when reformatting you can use the Calc
formatter:

| 3.25 | 0.5 |
|      |     |
#+TBLFM: $2=if("$1" == "nan", string(""), $1*0.15);E f-1

    (info "(org) Formula syntax for Calc")

    `if("$1" == "nan" || "$2" == "nan", string(""), $1 + $2); E f-1'
      Sum of the first two columns.  When at least one of the input
      fields is empty the Org table result field is set to empty.  `E'
      is required to not convert empty fields to 0.  `f-1' is an
      optional Calc format string similar to `%.1f' but leaves empty
      results empty.

See also
"Which float format shows the fraction part also when the latter is
zero?"
http://orgmode.org/worg/org-faq.html#table-float-fraction

Michael

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

end of thread, other threads:[~2017-06-23 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-22  7:25 empty cells in columns should be left emtpy when manipulating columns Uwe Brauer
2017-06-22  7:34 ` Nicolas Goaziou
2017-06-22  7:56   ` Uwe Brauer
2017-06-23 16:20     ` Michael Brand

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