Search code examples
emacsorg-mode

ignore zeros in org-mode table formula


I want a column formula that divides two cells, but ignore a row if the denumerator is zero.

Something like :

| 42 | 2 |          21 |
| 42 | 0 | round(42/0) |
#+TBLFM: $3=round($1/$2)

But with the third column empty instead of round(42/0).

Is that possible ?


Solution

  • This will do:

    | 42 | 2 | 21 |
    | 42 | 0 |    |
    #+TBLFM: $3=if($2>0,round($1/$2), string(""))
    

    string("") is the way to denote an empty cell. This, and the if() syntax, are described in the manual.