emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* delete, add new row
@ 2011-12-01 17:42 henry atting
  2011-12-01 20:23 ` Jonathan Leech-Pepin
  0 siblings, 1 reply; 3+ messages in thread
From: henry atting @ 2011-12-01 17:42 UTC (permalink / raw)
  To: emacs-orgmode

Suppose I have this table:

| month | expenses | average |
|-------+----------+---------|
|     1 |       20 |         |
|     2 |       30 |    25.0 |
|     3 |       40 |    30.0 |
#+TBLFM: @3$3..@>$3=vmean(@2$2..@0$2);%.1f

Then I want to delete the second row and add a new one at the bottom.
If I do so I get `#ERROR' on every recalculation.

| month | expenses | average |
|-------+----------+---------|
|     2 |       30 |  #ERROR |
|     3 |       40 |  #ERROR |
|     4 | 50       |  #ERROR |
#+TBLFM: @2$3..@>$3=vmean(@INVALID$2..@0$2);%.1f

If I push the second row to the bottom the
result is as if the last row is still the second one.

| month | expenses | average |
|-------+----------+---------|
|     2 |       30 |    30.0 |
|     3 |       40 |    30.0 |
|     1 |       20 |    20.0 |
#+TBLFM: @2$3..@>$3=vmean(@4$2..@0$2);%.1f


henry

-- 
http://literaturlatenight.de

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

* Re: delete, add new row
  2011-12-01 17:42 delete, add new row henry atting
@ 2011-12-01 20:23 ` Jonathan Leech-Pepin
  2011-12-02  9:59   ` henry atting
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Leech-Pepin @ 2011-12-01 20:23 UTC (permalink / raw)
  To: henry atting; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1623 bytes --]

I'm not sure as to the reason why it does so, but based on your example,
the formula is referencing the specific cell itself, rather than the
relative position of the cell.  If you change your formula to use a
relative reference, it will continue to work even when you add, remove and
move the rows.

#+TBLFM: @2$3..@>$3=vmean(@I$2..@0$2);%.1f
or
#+TBLFM: @2$3..@>$3=vmean(@<<$2..@0$2);%.1f
will both provide you with the result you seem to be looking for.  The
former uses your (first) horizontal line as the starting point, whereas the
latter uses the 2nd row from the top.

Regards,
Jonathan

On Thu, Dec 1, 2011 at 12:42, henry atting <nsmp_02@online.de> wrote:

> Suppose I have this table:
>
> | month | expenses | average |
> |-------+----------+---------|
> |     1 |       20 |         |
> |     2 |       30 |    25.0 |
> |     3 |       40 |    30.0 |
> #+TBLFM: @3$3..@>$3=vmean(@2$2..@0$2);%.1f
>
> Then I want to delete the second row and add a new one at the bottom.
> If I do so I get `#ERROR' on every recalculation.
>
> | month | expenses | average |
> |-------+----------+---------|
> |     2 |       30 |  #ERROR |
> |     3 |       40 |  #ERROR |
> |     4 | 50       |  #ERROR |
> #+TBLFM: @2$3..@>$3=vmean(@INVALID$2..@0$2);%.1f
>
> If I push the second row to the bottom the
> result is as if the last row is still the second one.
>
> | month | expenses | average |
> |-------+----------+---------|
> |     2 |       30 |    30.0 |
> |     3 |       40 |    30.0 |
> |     1 |       20 |    20.0 |
> #+TBLFM: @2$3..@>$3=vmean(@4$2..@0$2);%.1f
>
>
> henry
>
> --
> http://literaturlatenight.de
>
>
>

[-- Attachment #2: Type: text/html, Size: 2299 bytes --]

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

* Re: delete, add new row
  2011-12-01 20:23 ` Jonathan Leech-Pepin
@ 2011-12-02  9:59   ` henry atting
  0 siblings, 0 replies; 3+ messages in thread
From: henry atting @ 2011-12-02  9:59 UTC (permalink / raw)
  To: Jonathan Leech-Pepin; +Cc: emacs-orgmode

Jonathan Leech-Pepin <jonathan.leechpepin@gmail.com> writes:

> I'm not sure as to the reason why it does so, but based on your
> example, the formula is referencing the specific cell itself, rather
> than the relative position of the cell.  If you change your formula to
> use a relative reference, it will continue to work even when you add,
> remove and move the rows.
>
> #+TBLFM: @2$3..@>$3=vmean(@I$2..@0$2);%.1f 
> or
> #+TBLFM: @2$3..@>$3=vmean(@<<$2..@0$2);%.1f
> will both provide you with the result you seem to be looking for.  The
> former uses your (first) horizontal line as the starting point,
> whereas the latter uses the 2nd row from the top.
>
> Regards,
> Jonathan
>
> On Thu, Dec 1, 2011 at 12:42, henry atting <nsmp_02@online.de> wrote:
>
>     Suppose I have this table:
>     
>     | month | expenses | average |
>     |-------+----------+---------|
>     |     1 |       20 |         |
>     |     2 |       30 |    25.0 |
>     |     3 |       40 |    30.0 |
>     #+TBLFM: @3$3..@>$3=vmean(@2$2..@0$2);%.1f
>     
>     Then I want to delete the second row and add a new one at the
>     bottom.
>     If I do so I get `#ERROR' on every recalculation.
>     
>     | month | expenses | average |
>     |-------+----------+---------|
>     |     2 |       30 |  #ERROR |
>     |     3 |       40 |  #ERROR |
>     |     4 | 50       |  #ERROR |
>     #+TBLFM: @2$3..@>$3=vmean(@INVALID$2..@0$2);%.1f
>     
>     If I push the second row to the bottom the
>     result is as if the last row is still the second one.
>     
>     | month | expenses | average |
>     |-------+----------+---------|
>     |     2 |       30 |    30.0 |
>     |     3 |       40 |    30.0 |
>     |     1 |       20 |    20.0 |
>     #+TBLFM: @2$3..@>$3=vmean(@4$2..@0$2);%.1f
>     

Ah, I see the problem; and thanks, it works fine now.

henry

-- 
http://literaturlatenight.de

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

end of thread, other threads:[~2011-12-02  9:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-01 17:42 delete, add new row henry atting
2011-12-01 20:23 ` Jonathan Leech-Pepin
2011-12-02  9:59   ` henry atting

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