Re: Org table: emphasizing calculated cell

2021-08-27 Thread Jarmo Hurri


Greetings Norwid.

Norwid Behrnd  writes:

> Let's use your idea to use /multiple table formulae/.  Contrasting to
> your attempt, I don't mind to go the extra mile and to run a cheap
> computation twice for a result already in hand.  As a MWE 
>
> ```
> | quantity  |  value |
> | A |  1 |
> | B |  3 |
> | ratio A/B | *0.33* |
> | ratio + 1 |   1.33 |
>
> #+TBLFM: @4$2 = @2/@3; *%.2f* :: @5$2 = @2/@3 + 1; %.2f
> ```

Thanks, that is indeed a working approach. As you suspected, I would go
an extra mile or ten to avoid repeating formulae. ;)

Have fun and stay safe,

Jarmo




Re: Org table: emphasizing calculated cell

2021-08-27 Thread Jarmo Hurri
Nick Dokos  writes:

> Jarmo Hurri  writes:
>> This solution seems to change the contents of a cell, not only its
>> formatting. So the following, where I try to increase the value of "C"
>> by one, leads to an error:
>>
>> ```
>> | quantity | value  |
>> |--+|
>> | A| 1  |
>> | B| 3  |
>> |--+|
>> | *C*  | *0.33* |
>> | D| #ERROR |
>>
>> #+TBLFM: @4$2=@-2/@-1; *%.2f*::@5$2=@-1+1
>> ```
>>
>> I wonder if there is a way around this effect?
>
> The error here is that `*0.33*' is no longer a string that can be
> converted to a number, so the calculator barfs.

Yes, that is obvious. The underlying question is whether it is possible
to cleanly separate presentation from contents. Here they are mixed.

All the best,

Jarmo




Re: Org table: emphasizing calculated cell

2021-08-27 Thread Samuel Wales
out of curiosity, do common spreadsheets implement the feature of
distinguishing calculated results from entered values?  i find myself
wanting that too, but don't know if that desire is unusual.


On 8/27/21, Nick Dokos  wrote:
> Jarmo Hurri  writes:
>
>> Greetings Norwid.
>>
>> Norwid Behrnd  writes:
>>
>>> try extending the format of the table formula with asterisks, i.e.
>>>
>>> ```
>>> | quantity |  value |
>>> |--+|
>>> | A|  1 |
>>> | B|  3 |
>>> |--+|
>>> | *C*  | *0.33* |
>>>
>>> #+TBLFM:  @4$2=@-2/@-1; *%.2f*
>>> ```
>>>
>>> Subsequently, issue the call ```C-c *``` for an update while the
>>> cursor is within the table.  This approach works well enough for me
>>> (equally for emphasis with enclosing forward slashes, or underscores)
>>> in Emacs' native display (backed by elpa-org 9.4.0) as well as for a
>>> subsequent export into .html and display (e.g., in Firefox), or .tex.
>>
>> Excellent, this is a working solution for the basic case. Much
>> appreciated!
>>
>> This solution seems to change the contents of a cell, not only its
>> formatting. So the following, where I try to increase the value of "C"
>> by one, leads to an error:
>>
>> ```
>> | quantity | value  |
>> |--+|
>> | A| 1  |
>> | B| 3  |
>> |--+|
>> | *C*  | *0.33* |
>> | D| #ERROR |
>>
>> #+TBLFM: @4$2=@-2/@-1; *%.2f*::@5$2=@-1+1
>> ```
>>
>> I wonder if there is a way around this effect?
>>
>
> The error here is that `*0.33*' is no longer a string that can be converted
> to a number,
> so the calculator barfs.
>
> TUrn on formula debugging with `C-c {' and try evaluating it.
>
> --
> Nick
>
> "There are only two hard problems in computer science: cache
> invalidation, naming things, and off-by-one errors." -Martin Fowler
>
>
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html



Re: Org table: emphasizing calculated cell

2021-08-27 Thread Nick Dokos
Jarmo Hurri  writes:

> Greetings Norwid.
>
> Norwid Behrnd  writes:
>
>> try extending the format of the table formula with asterisks, i.e.
>>
>> ```
>> | quantity |  value |
>> |--+|
>> | A|  1 |
>> | B|  3 |
>> |--+|
>> | *C*  | *0.33* |
>>
>> #+TBLFM:  @4$2=@-2/@-1; *%.2f*
>> ```
>>
>> Subsequently, issue the call ```C-c *``` for an update while the
>> cursor is within the table.  This approach works well enough for me
>> (equally for emphasis with enclosing forward slashes, or underscores)
>> in Emacs' native display (backed by elpa-org 9.4.0) as well as for a
>> subsequent export into .html and display (e.g., in Firefox), or .tex.
>
> Excellent, this is a working solution for the basic case. Much
> appreciated!
>
> This solution seems to change the contents of a cell, not only its
> formatting. So the following, where I try to increase the value of "C"
> by one, leads to an error:
>
> ```
> | quantity | value  |
> |--+|
> | A| 1  |
> | B| 3  |
> |--+|
> | *C*  | *0.33* |
> | D| #ERROR |
>
> #+TBLFM: @4$2=@-2/@-1; *%.2f*::@5$2=@-1+1
> ```
>
> I wonder if there is a way around this effect?
>

The error here is that `*0.33*' is no longer a string that can be converted to 
a number,
so the calculator barfs.

TUrn on formula debugging with `C-c {' and try evaluating it.

-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler




Re: Org table: emphasizing calculated cell

2021-08-26 Thread Jarmo Hurri


Greetings Norwid.

Norwid Behrnd  writes:

> try extending the format of the table formula with asterisks, i.e.
>
> ```
> | quantity |  value |
> |--+|
> | A|  1 |
> | B|  3 |
> |--+|
> | *C*  | *0.33* |
>
> #+TBLFM:  @4$2=@-2/@-1; *%.2f*
> ```
>
> Subsequently, issue the call ```C-c *``` for an update while the
> cursor is within the table.  This approach works well enough for me
> (equally for emphasis with enclosing forward slashes, or underscores)
> in Emacs' native display (backed by elpa-org 9.4.0) as well as for a
> subsequent export into .html and display (e.g., in Firefox), or .tex.

Excellent, this is a working solution for the basic case. Much
appreciated!

This solution seems to change the contents of a cell, not only its
formatting. So the following, where I try to increase the value of "C"
by one, leads to an error:

```
| quantity | value  |
|--+|
| A| 1  |
| B| 3  |
|--+|
| *C*  | *0.33* |
| D| #ERROR |
#+TBLFM: @4$2=@-2/@-1; *%.2f*::@5$2=@-1+1
```

I wonder if there is a way around this effect?

Jarmo




Org table: emphasizing calculated cell

2021-08-25 Thread Jarmo Hurri


Greetings.

In the table below, the text in the first column of the last row is
emphasized. What is (an easy way) to emphasize the calculated value in
the second column of the last row?

| quantity | value |
|--+---|
| A| 1 |
| B| 3 |
|--+---|
| *C*  |  0.33 |
#+TBLFM: @4$2=@-2/@-1;%.2f

All the best,

Jarmo