emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* table formula question
@ 2007-06-05 21:40 Eddward DeVilla
  2007-06-06  1:39 ` William Henney
  0 siblings, 1 reply; 3+ messages in thread
From: Eddward DeVilla @ 2007-06-05 21:40 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

    I'm having trouble trying to figure out what I've got wrong here.
Given the table

* wealth management
  |--------------------------+--------+-------|
  | item                     | amount | total |
  |--------------------------+--------+-------|
  | paid                     |  50.00 |       |
  | baby's new part of shoes | -25.00 |       |
  | chip                     |  -2.50 |       |
  |--------------------------+--------+-------|
#+TBLFM: $3='(+ @-1 $-1)


I would expect to get the results

* wealth management
  |--------------------------+--------+-------|
  | item                     | amount | total |
  |--------------------------+--------+-------|
  | paid                     |  50.00 | 50.00 |
  | baby's new part of shoes | -25.00 | 25.00 |
  | chip                     |  -2.50 | 22.50 |
  |--------------------------+--------+-------|
#+TBLFM: $3='(+ @-1 $-1)


But instead I just get

* wealth management
  |--------------------------+--------+--------|
  | item                     | amount | total  |
  |--------------------------+--------+--------|
  | paid                     |  50.00 | #ERROR |
  | baby's new part of shoes | -25.00 | #ERROR |
  | chip                     |  -2.50 | #ERROR |
  |--------------------------+--------+--------|
#+TBLFM: $3='(+ @-1 $-1)


I'm sure I'm missing something.  Is a table like this even possible?

Edd

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

* Re: table formula question
  2007-06-05 21:40 table formula question Eddward DeVilla
@ 2007-06-06  1:39 ` William Henney
  2007-06-06  1:48   ` Eddward DeVilla
  0 siblings, 1 reply; 3+ messages in thread
From: William Henney @ 2007-06-06  1:39 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Eddward DeVilla

Hi Eddward

Does this do what you want?

* wealth management
 |--------------------------+---------+---------|
 | item                     |  amount | balance |
 |--------------------------+---------+---------|
 | paid                     |   50.00 |   50.00 |
 | baby's new part of shoes |  -25.00 |   25.00 |
 | chip                     |   -2.50 |   22.50 |
 | my birthday!             |  100.00 |  122.50 |
 | speeding fine :(         | -200.00 |  -77.50 |
 |--------------------------+---------+---------|
#+TBLFM: $3=vsum(@-I$-1..$-1);f2

By explicitly doing the summation, I avoid any dependence on the order
in which each row is calculated. I think that your version fails
because your formula makes no sense for the first row: you can't add a
string ("total") to a float (50.00).

Cheers

Will

On 6/5/07, Eddward DeVilla <eddward@gmail.com> wrote:
> Hi,
>
>     I'm having trouble trying to figure out what I've got wrong here.
> Given the table
>
> * wealth management
>   |--------------------------+--------+-------|
>   | item                     | amount | total |
>   |--------------------------+--------+-------|
>   | paid                     |  50.00 |       |
>   | baby's new part of shoes | -25.00 |       |
>   | chip                     |  -2.50 |       |
>   |--------------------------+--------+-------|
> #+TBLFM: $3='(+ @-1 $-1)
>
>
> I would expect to get the results
>
> * wealth management
>   |--------------------------+--------+-------|
>   | item                     | amount | total |
>   |--------------------------+--------+-------|
>   | paid                     |  50.00 | 50.00 |
>   | baby's new part of shoes | -25.00 | 25.00 |
>   | chip                     |  -2.50 | 22.50 |
>   |--------------------------+--------+-------|
> #+TBLFM: $3='(+ @-1 $-1)
>
>
> But instead I just get
>
> * wealth management
>   |--------------------------+--------+--------|
>   | item                     | amount | total  |
>   |--------------------------+--------+--------|
>   | paid                     |  50.00 | #ERROR |
>   | baby's new part of shoes | -25.00 | #ERROR |
>   | chip                     |  -2.50 | #ERROR |
>   |--------------------------+--------+--------|
> #+TBLFM: $3='(+ @-1 $-1)
>
>
> I'm sure I'm missing something.  Is a table like this even possible?
>
> Edd
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>


-- 

  Dr William Henney, Centro de Radioastronomía y Astrofísica,
  Universidad Nacional Autónoma de México, Campus Morelia

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

* Re: table formula question
  2007-06-06  1:39 ` William Henney
@ 2007-06-06  1:48   ` Eddward DeVilla
  0 siblings, 0 replies; 3+ messages in thread
From: Eddward DeVilla @ 2007-06-06  1:48 UTC (permalink / raw)
  To: William Henney; +Cc: emacs-orgmode

That looks like it will work.  I don't have calc on my work system so
I'll have to do the elisp equivalent but that won't be hard.  Say
something like so:

* wealth management
 |--------------------------+---------+---------|
 | item                     |  amount | balance |
 |--------------------------+---------+---------|
 | paid                     |   50.00 |   50.00 |
 | baby's new pair of shoes |  -25.00 |   25.00 |
 | chips                    |   -2.50 |   22.50 |
 | my birthday!             |  100.00 |  122.50 |
 | speeding fine :(         | -200.00 |  -77.50 |
 |--------------------------+---------+---------|
#+TBLFM: $3='(apply '+ '(@-I$-1..$-1));N%.2f

Thanks,
Edd

On 6/5/07, William Henney <whenney@gmail.com> wrote:
> Hi Eddward
>
> Does this do what you want?
>
> * wealth management
>  |--------------------------+---------+---------|
>  | item                     |  amount | balance |
>  |--------------------------+---------+---------|
>  | paid                     |   50.00 |   50.00 |
>  | baby's new part of shoes |  -25.00 |   25.00 |
>  | chip                     |   -2.50 |   22.50 |
>  | my birthday!             |  100.00 |  122.50 |
>  | speeding fine :(         | -200.00 |  -77.50 |
>  |--------------------------+---------+---------|
> #+TBLFM: $3=vsum(@-I$-1..$-1);f2
>
> By explicitly doing the summation, I avoid any dependence on the order
> in which each row is calculated. I think that your version fails
> because your formula makes no sense for the first row: you can't add a
> string ("total") to a float (50.00).
>
> Cheers
>
> Will
>
> On 6/5/07, Eddward DeVilla <eddward@gmail.com> wrote:
> > Hi,
> >
> >     I'm having trouble trying to figure out what I've got wrong here.
> > Given the table
> >
> > * wealth management
> >   |--------------------------+--------+-------|
> >   | item                     | amount | total |
> >   |--------------------------+--------+-------|
> >   | paid                     |  50.00 |       |
> >   | baby's new part of shoes | -25.00 |       |
> >   | chip                     |  -2.50 |       |
> >   |--------------------------+--------+-------|
> > #+TBLFM: $3='(+ @-1 $-1)
> >
> >
> > I would expect to get the results
> >
> > * wealth management
> >   |--------------------------+--------+-------|
> >   | item                     | amount | total |
> >   |--------------------------+--------+-------|
> >   | paid                     |  50.00 | 50.00 |
> >   | baby's new part of shoes | -25.00 | 25.00 |
> >   | chip                     |  -2.50 | 22.50 |
> >   |--------------------------+--------+-------|
> > #+TBLFM: $3='(+ @-1 $-1)
> >
> >
> > But instead I just get
> >
> > * wealth management
> >   |--------------------------+--------+--------|
> >   | item                     | amount | total  |
> >   |--------------------------+--------+--------|
> >   | paid                     |  50.00 | #ERROR |
> >   | baby's new part of shoes | -25.00 | #ERROR |
> >   | chip                     |  -2.50 | #ERROR |
> >   |--------------------------+--------+--------|
> > #+TBLFM: $3='(+ @-1 $-1)
> >
> >
> > I'm sure I'm missing something.  Is a table like this even possible?
> >
> > Edd
> >
> >
> > _______________________________________________
> > Emacs-orgmode mailing list
> > Emacs-orgmode@gnu.org
> > http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> >
>
>
> --
>
>   Dr William Henney, Centro de Radioastronomía y Astrofísica,
>   Universidad Nacional Autónoma de México, Campus Morelia
>

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

end of thread, other threads:[~2007-06-06  1:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-05 21:40 table formula question Eddward DeVilla
2007-06-06  1:39 ` William Henney
2007-06-06  1:48   ` Eddward DeVilla

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