emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Spreadsheet question
@ 2008-12-03 21:34 Tassilo Horn
  2008-12-04  8:06 ` Carsten Dominik
  0 siblings, 1 reply; 5+ messages in thread
From: Tassilo Horn @ 2008-12-03 21:34 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I have this table:

| header |
|--------|
|      1 |
|      1 |
|--------|
|      0 |
#+TBLFM: @4$1=vsum(@2..@-1)

The cell containing 0 should sum up all values of the column's rows
above.  But C-u C-c C-c gives 2, then 4, then 6, then 8...

Reading the docs I found out that @-1 won't cross hlines, so now I use
-I instead which works.  But still I don't understand the @-1 behavior.
Even if knowing that it doesn't cross hlines I'd expect it to calculate
the correct value or at least error because there's no row above @4
before the next hline.  So why is (equal @-1 @0) here?

Bye,
Tassilo

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

* Re: Spreadsheet question
  2008-12-03 21:34 Spreadsheet question Tassilo Horn
@ 2008-12-04  8:06 ` Carsten Dominik
  2008-12-04 10:49   ` Tassilo Horn
  0 siblings, 1 reply; 5+ messages in thread
From: Carsten Dominik @ 2008-12-04  8:06 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode

Hi Tassilo,

@-1 references the row above the current.  If that is a hline, if  
actually
references the current line.

So you are asking Org-mode to sum lines 2 - 6, which includes the  
result line.  So each time the calculation is done, it add the two  
ones to the result from the previous calculation.

- Carsten

On Dec 3, 2008, at 10:34 PM, Tassilo Horn wrote:

> Hi all,
>
> I have this table:
>
> | header |
> |--------|
> |      1 |
> |      1 |
> |--------|
> |      0 |
> #+TBLFM: @4$1=vsum(@2..@-1)
>
> The cell containing 0 should sum up all values of the column's rows
> above.  But C-u C-c C-c gives 2, then 4, then 6, then 8...
>
> Reading the docs I found out that @-1 won't cross hlines, so now I use
> -I instead which works.  But still I don't understand the @-1  
> behavior.
> Even if knowing that it doesn't cross hlines I'd expect it to  
> calculate
> the correct value or at least error because there's no row above @4
> before the next hline.  So why is (equal @-1 @0) here?
>
> Bye,
> Tassilo
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Spreadsheet question
  2008-12-04  8:06 ` Carsten Dominik
@ 2008-12-04 10:49   ` Tassilo Horn
  2008-12-05  7:26     ` Carsten Dominik
  0 siblings, 1 reply; 5+ messages in thread
From: Tassilo Horn @ 2008-12-04 10:49 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <dominik@science.uva.nl> writes:

Hi Carsten,

> @-1 references the row above the current.  If that is a hline, if
> actually references the current line.

Yes, I see that, but I wonder if that's actually the right thing to do.
IMO defaulting to some cell/row/column which is not referenced correctly
might obscure wrong formulas.

For example, in my case the first calculation gave 2 which is correct
and only the second recalculation shows me that the forumla is wrong.
So I'd prefer an #ERROR if a reference doesn't exist.

Bye,
Tassilo

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

* Re: Spreadsheet question
  2008-12-04 10:49   ` Tassilo Horn
@ 2008-12-05  7:26     ` Carsten Dominik
  2008-12-05 12:23       ` Carsten Dominik
  0 siblings, 1 reply; 5+ messages in thread
From: Carsten Dominik @ 2008-12-05  7:26 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode

Hi Tassilo,

I can see that this could be confusing, and maybe it should throw an  
error.

The use-ase fo this are running means as column formulas
that would be undefined for he first few rows in.  Consider
the following table:


| i | nn | mean of last 3 |
|---+----+----------------|
| 1 |  4 |           4.00 |
| 2 |  7 |           5.50 |
| 3 |  2 |           4.33 |
| 4 |  4 |           4.33 |
| 5 |  5 |           3.67 |
| 6 |  7 |           5.33 |
| 7 |  9 |           7.00 |
| 8 | 22 |          12.67 |
#+TBLFM: $3=vmean([@-2$-1..$-1]);%.2f

I am not sure how common this use is and who would
be hurt by turning this behavior into an error.

- Carsten

On Dec 4, 2008, at 11:49 AM, Tassilo Horn wrote:

> Carsten Dominik <dominik@science.uva.nl> writes:
>
> Hi Carsten,
>
>> @-1 references the row above the current.  If that is a hline, if
>> actually references the current line.
>
> Yes, I see that, but I wonder if that's actually the right thing to  
> do.
> IMO defaulting to some cell/row/column which is not referenced  
> correctly
> might obscure wrong formulas.
>
> For example, in my case the first calculation gave 2 which is correct
> and only the second recalculation shows me that the forumla is wrong.
> So I'd prefer an #ERROR if a reference doesn't exist.
>
> Bye,
> Tassilo

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

* Re: Spreadsheet question
  2008-12-05  7:26     ` Carsten Dominik
@ 2008-12-05 12:23       ` Carsten Dominik
  0 siblings, 0 replies; 5+ messages in thread
From: Carsten Dominik @ 2008-12-05 12:23 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Tassilo Horn, emacs-orgmode

Actually, thinking more about this, I think that Tassilo is right.

Therefore, from now on, this condition will throw an error.
I would like to make this #ERROR in the table cell, but
this is not easy, so for the time being, it really stops
the evaluation with an error message.

Thanks, Tassilo, for pointing to this issue.

- Carsten

On Dec 5, 2008, at 8:26 AM, Carsten Dominik wrote:

> Hi Tassilo,
>
> I can see that this could be confusing, and maybe it should throw an  
> error.
>
> The use-ase fo this are running means as column formulas
> that would be undefined for he first few rows in.  Consider
> the following table:
>
>
> | i | nn | mean of last 3 |
> |---+----+----------------|
> | 1 |  4 |           4.00 |
> | 2 |  7 |           5.50 |
> | 3 |  2 |           4.33 |
> | 4 |  4 |           4.33 |
> | 5 |  5 |           3.67 |
> | 6 |  7 |           5.33 |
> | 7 |  9 |           7.00 |
> | 8 | 22 |          12.67 |
> #+TBLFM: $3=vmean([@-2$-1..$-1]);%.2f
>
> I am not sure how common this use is and who would
> be hurt by turning this behavior into an error.
>
> - Carsten
>
> On Dec 4, 2008, at 11:49 AM, Tassilo Horn wrote:
>
>> Carsten Dominik <dominik@science.uva.nl> writes:
>>
>> Hi Carsten,
>>
>>> @-1 references the row above the current.  If that is a hline, if
>>> actually references the current line.
>>
>> Yes, I see that, but I wonder if that's actually the right thing to  
>> do.
>> IMO defaulting to some cell/row/column which is not referenced  
>> correctly
>> might obscure wrong formulas.
>>
>> For example, in my case the first calculation gave 2 which is correct
>> and only the second recalculation shows me that the forumla is wrong.
>> So I'd prefer an #ERROR if a reference doesn't exist.
>>
>> Bye,
>> Tassilo
>

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

end of thread, other threads:[~2008-12-05 12:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-03 21:34 Spreadsheet question Tassilo Horn
2008-12-04  8:06 ` Carsten Dominik
2008-12-04 10:49   ` Tassilo Horn
2008-12-05  7:26     ` Carsten Dominik
2008-12-05 12:23       ` Carsten Dominik

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