emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Sum marked values in table
@ 2013-03-22 10:19 Stefan Nobis
  2013-03-23  9:42 ` Michael Brand
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Nobis @ 2013-03-22 10:19 UTC (permalink / raw)
  To: emacs-orgmode

Hi.

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 @>$> or is a custom
lisp function needed for this?

-- 
Until the next mail...,
Stefan.

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

* Re: Sum marked values in table
  2013-03-22 10:19 Sum marked values in table Stefan Nobis
@ 2013-03-23  9:42 ` Michael Brand
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Brand @ 2013-03-23  9:42 UTC (permalink / raw)
  To: Org Mode

Hi Stefan

On Fri, Mar 22, 2013 at 11:19 AM, Stefan Nobis <stefan-ml@snobis.de> 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

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

end of thread, other threads:[~2013-03-23  9:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-22 10:19 Sum marked values in table Stefan Nobis
2013-03-23  9:42 ` Michael Brand

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