From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Re: Sum marked values in table Date: Sat, 23 Mar 2013 10:42:18 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:57468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJKxy-0002cH-7M for emacs-orgmode@gnu.org; Sat, 23 Mar 2013 05:42:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJKxw-0003at-FI for emacs-orgmode@gnu.org; Sat, 23 Mar 2013 05:42:22 -0400 Received: from mail-la0-x22b.google.com ([2a00:1450:4010:c03::22b]:44633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJKxw-0003aZ-8n for emacs-orgmode@gnu.org; Sat, 23 Mar 2013 05:42:20 -0400 Received: by mail-la0-f43.google.com with SMTP id ek20so8635090lab.2 for ; Sat, 23 Mar 2013 02:42:18 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode Hi Stefan On Fri, Mar 22, 2013 at 11:19 AM, Stefan Nobis 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 | | | | | | | | |--------+-------+---------+---------+------+------| | 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