Re: [O] date calculation in org table

2013-05-23 Thread Christian Moe



Hi, Dude,

Not quite sure why that doesn't work (nor gives an error message about
trying to set the same cell). However, it will work if you specify the
cell range:

 @4$4=$sdate + $3::$4=@-1$4+$3
^^   
  @4$4=$sdate + $3::@5$4..@20$4=@-1$4+$3
^^^

BTW, it's OK to omit the reference to the same column, so you can save
two characters:

  @4$4=$sdate + $3::@5$4..@20$4=@-1$4+$3
   ^^
  @4$4=$sdate + $3::@5$4..@20$4=@-1+$3 

Yours,
Christian



Re: [O] date calculation in org table

2013-05-23 Thread The Dude
- Christian Moe writes:

 Hi, Dude,

 Not quite sure why that doesn't work (nor gives an error message about
 trying to set the same cell). However, it will work if you specify the
 cell range:

 @4$4=$sdate + $3::$4=@-1$4+$3
 ^^   
   @4$4=$sdate + $3::@5$4..@20$4=@-1$4+$3
 ^^^

Yep, that works perfectly.  The only drawback is when I have to add a
new row etc. but I can live with that.  Thanks!

 BTW, it's OK to omit the reference to the same column, so you can save
 two characters:

   @4$4=$sdate + $3::@5$4..@20$4=@-1$4+$3
^^
   @4$4=$sdate + $3::@5$4..@20$4=@-1+$3 

Got it.

 Yours,
 Christian

cheers
-- 
-dude

Too brief? Here's why! http://emailcharter.org




Re: [O] date calculation in org table

2013-05-23 Thread Michael Brand
Hi Rafal

On Thu, May 23, 2013 at 8:43 AM, The Dude rafal.kowal...@mac.com wrote:

 The problem is that when I change the $sdate and recalculate the whole
 table with `C-u C-u C-c C-c' only the element @4$4 is set.  It seems
 like the column formula doesn't apply to the other fields.

This I consider a bug, minimal example:

| # | a | a |
|   | b |   |
#+TBLFM: $3 = $2

|   | a | a |
|   | b | b |
#+TBLFM: $3 = $2

 |   | WP | Days | Arrival Date |
 |---++--+--|
 | # ||  | 2013-06-05 Wed |
 | ^ ||  | sdate|
 |---++--+--|
 |   |  1 |4 | 2013-06-09 Sun |
 |   |  - |2 | 2013-06-11 Tue |
 |   |  2 |4 | 2013-06-15 Sat |
 |   |  - |2 | 2013-06-17 Mon |
 |   |  3 |1 | 2013-06-18 Tue |
 |   |  4 |2 | 2013-06-20 Thu |
 |   |  5 |1 | 2013-06-21 Fri |
 |   |  - |2 | 2013-06-23 Sun |
 |   |  6 |1 | 2013-06-24 Mon |
 |   |  7 |2 | 2013-06-26 Wed |
 |   |  - |1 | 2013-06-27 Thu |
 |   |  8 |1 | 2013-06-28 Fri |
 |   |  9 |1 | 2013-06-29 Sat |
 |   |  - |3 | 2013-07-02 Tue |
 |   | 10 |3 | 2013-07-05 Fri |
 |   |  - |1 | 2013-07-06 Sat |
 |   | 11 |2 | 2013-07-08 Mon |
 |---++--+--|
 |   ||   33 | 2013-07-08 Mon |
 #+TBLFM: @4$4=$sdate + 
 $3::$4=@-1$4+$3::@21$3=vsum(@II..@III)::@21$4=@III-1::$sdate=2013-06-05 Wed

Let me suggest one more variant. No row numbers, uses the fact that
the formula for $3 is not evaluated in the header and it circumvents
the bug:

|   | WP | Days | Arrival Date |
|   ||  | 2013-06-05 Wed |
|---++--+--|
|   |  1 |4 | 2013-06-09 Sun |
|   |  - |2 | 2013-06-11 Tue |
|   |  2 |4 | 2013-06-15 Sat |
|   |  - |2 | 2013-06-17 Mon |
|   |  3 |1 | 2013-06-18 Tue |
|   |  4 |2 | 2013-06-20 Thu |
|   |  5 |1 | 2013-06-21 Fri |
|   |  - |2 | 2013-06-23 Sun |
|   |  6 |1 | 2013-06-24 Mon |
|   |  7 |2 | 2013-06-26 Wed |
|   |  - |1 | 2013-06-27 Thu |
|   |  8 |1 | 2013-06-28 Fri |
|   |  9 |1 | 2013-06-29 Sat |
|   |  - |3 | 2013-07-02 Tue |
|   | 10 |3 | 2013-07-05 Fri |
|   |  - |1 | 2013-07-06 Sat |
|   | 11 |2 | 2013-07-08 Mon |
|---++--+--|
|   ||   33 | 2013-07-08 Mon |
#+TBLFM: $4 = @-1 + $3 :: @$3 = vsum(@I..@II) :: @$4 = @-1

Michael



Re: [O] date calculation in org table

2013-05-23 Thread The Dude
- Michael Brand writes:

[...]

 Let me suggest one more variant. No row numbers, uses the fact that
 the formula for $3 is not evaluated in the header and it circumvents
 the bug:

 |   | WP | Days | Arrival Date |
 |   ||  | 2013-06-05 Wed |
 |---++--+--|
 |   |  1 |4 | 2013-06-09 Sun |
 |   |  - |2 | 2013-06-11 Tue |
 |   |  2 |4 | 2013-06-15 Sat |
 |   |  - |2 | 2013-06-17 Mon |
 |   |  3 |1 | 2013-06-18 Tue |
 |   |  4 |2 | 2013-06-20 Thu |
 |   |  5 |1 | 2013-06-21 Fri |
 |   |  - |2 | 2013-06-23 Sun |
 |   |  6 |1 | 2013-06-24 Mon |
 |   |  7 |2 | 2013-06-26 Wed |
 |   |  - |1 | 2013-06-27 Thu |
 |   |  8 |1 | 2013-06-28 Fri |
 |   |  9 |1 | 2013-06-29 Sat |
 |   |  - |3 | 2013-07-02 Tue |
 |   | 10 |3 | 2013-07-05 Fri |
 |   |  - |1 | 2013-07-06 Sat |
 |   | 11 |2 | 2013-07-08 Mon |
 |---++--+--|
 |   ||   33 | 2013-07-08 Mon |
 #+TBLFM: $4 = @-1 + $3 :: @$3 = vsum(@I..@II) :: @$4 = @-1

That's a very nice variant and works well.  Thanks.  

BTW, what is the difference between `C-u C-c C-c' and `C-u C-*'?  I
thought they're doing the same thing.

 Michael

cheers
-- 
-dude

Too brief? Here's why! http://emailcharter.org




Re: [O] date calculation in org table

2013-05-23 Thread Michael Brand
Hi Rafal

On Thu, May 23, 2013 at 4:47 PM, The Dude rafal.kowal...@mac.com wrote:
 BTW, what is the difference between `C-u C-c C-c' and `C-u C-*'?  I
 thought they're doing the same thing.

- `C-u C-c *' or `C-u C-c C-c': recalculate once
- `C-u C-u C-c *' or `C-u C-u C-c C-c' (`org-table-iterate'): repeat
  recalculation until no further changes occur
See http://orgmode.org/org.html#Updating-the-table

Michael