[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Sum marked values in table
From: |
Michael Brand |
Subject: |
Re: [O] Sum marked values in table |
Date: |
Sat, 23 Mar 2013 10:42:18 +0100 |
Hi Stefan
On Fri, Mar 22, 2013 at 11:19 AM, Stefan Nobis <address@hidden> wrote:
> Is there any way to somehow mark cells in an org-table and then sum
> over all marked cells of the whole table. For example in the following
> table I marked some time values bold:
>
> | | Col 1 | Col 2 | Col 3 | Col4 | Sum |
> |--------+-------+--------+--------+------+----------|
> | Row 1 | | *1:00* | | | 01:00:00 |
> | Row 2 | 8:30 | 6:30 | *7:00* | | 22:00:00 |
> |--------+-------+--------+--------+------+----------|
> | Sum | | | | | 23:00:00 |
> | Marked | | | | | 08:00:00 |
> #+TBLFM: @>$>=??????::@>>$>=vsum(@<<..@>>>);T::$>=vsum($<<..$>>);T
>
> Exist some clever trick to be used as formula for @>$>
For numbers instead of times yes, there is often fun with complex
numbers:
| | Col 1 | Col 2 | Col 3 | Col4 | Sum |
| | <r> | <r> | <r> | <r> | |
|--------+-------+---------+---------+------+------|
| Row 1 | | i * 1.0 | | | 1.0 |
| Row 2 | 8.5 | 6.5 | i * 7.0 | | 22.0 |
|--------+-------+---------+---------+------+------|
| Sum | | | | | 23.0 |
| Marked | | | | | 8.0 |
#+TBLFM: $> = re(vsum($<<..$>>)) + im(vsum($<<..$>>)) +.0; f-1 ::
@>>$> = vsum(@<<<..@>>>); f-1 :: @>$> = im(vsum(@<<<$<<..@>>>$>>))
+.0; f-1
The marked fields can be highlighted with hi-lock-mode.
Unfortunately it does not work with time format because the Org time
format parser reasonably does not deal with a Calc expression in a
field but "only" with a pure time.
For "+.0" and "f-1" see
http://orgmode.org/worg/org-faq.html#table-float-fraction
> or is a custom lisp function needed for this?
For time calculation I would say yes and to use Org emphasis as you
suggest with bold seems a good idea. A custom function would be
necessary not only for @>$> but also for the other formulas because
Org does not omit emphasis when parsing the fields (which would be a
nice feature, maybe always or only together with some new format
specifier).
Michael