From: Michael Brand <michael.ch.brand@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Sum marked values in table
Date: Sat, 23 Mar 2013 10:42:18 +0100 [thread overview]
Message-ID: <CALn3zog81+Yp90-aouDUphmTTrA=goz_Qx9G0kWGjkRyYSNzBQ@mail.gmail.com> (raw)
In-Reply-To: <m1620jybx9.fsf@nobis-it.eu>
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
prev parent reply other threads:[~2013-03-23 9:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-22 10:19 Sum marked values in table Stefan Nobis
2013-03-23 9:42 ` Michael Brand [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALn3zog81+Yp90-aouDUphmTTrA=goz_Qx9G0kWGjkRyYSNzBQ@mail.gmail.com' \
--to=michael.ch.brand@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).