emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Brett Presnell <presnell@member.fsf.org>
To: Michael Brand <michael.ch.brand@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Table calculation
Date: Sat, 20 Feb 2016 17:48:45 -0500	[thread overview]
Message-ID: <87lh6fdmlu.fsf@ufl.edu> (raw)
In-Reply-To: <CALn3zoj1GbdM7xBaccbJgTMOzvz_sywC-_9C+oxZavDnFjCB-Q@mail.gmail.com>


Fantastic.  Thanks Michael.

Michael Brand <michael.ch.brand@gmail.com> writes:

> Hi Brett
>
> On Sat, Feb 20, 2016 at 8:41 PM, Brett Presnell <presnell@member.fsf.org> wrote:
>
>> In the following table, the last row gives the number of empty cells
>> following the last nonempty cell in each column (except the first column
>> of course).  I would like to create a TBLFM formula that does this
>> calculation for me automatically.  Some time ago I tried using
>> org-lookup-last and org-lookup-all for this, but I never got it to work.
>> Any ideas/solutions?
>>
>> |   Date | AA | BB | CC | DD | EE | FF | GG | HH | II | JJ | KK | LL | MM |
>> |--------+----+----+----+----+----+----+----+----+----+----+----+----+----|
>> |      / | <> | <> | <> | <> | <> | <> | <> | <> | <> | <> | <> | <> | <> |
>> | 201005 |    |    |    |    |  1 |    |    |  1 |    |    |    |  1 |    |
>> | 201008 |    |    |    |  1 |    |    |    |    |    |    |    |    |    |
>> | 201012 |    |    |    |    |    |    |    |    |    |    |    |    |    |
>> | 201105 |    |    |    |    |    |  1 |    |    |    |    |    |    |    |
>> | 201108 |    |    |    |    |    |    |  1 |    |    |    |    |    |    |
>> | 201112 |    |    |    |    |    |    |    |    |    |  1 |    |    |    |
>> | 201205 |    |    |    |    |    |    |    |    |    |    |    |    |    |
>> | 201208 |    |    |    |    |    |    |    |    |    |    |    |    |    |
>> | 201212 |    |    |    |    |    |    |    |    |  1 |    |    |    |    |
>> | 201305 |    |    |  1 |    |    |    |    |  2 |    |    |  1 |    |    |
>> | 201308 |  1 |    |    |    |    |    |    |    |    |    |    |    |    |
>> | 201312 |    |    |    |    |    |    |    |    |    |    |    |    |  1 |
>> | 201405 |    |    |    |    |    |    |    |  1 |    |    |    |  1 |    |
>> | 201408 |    |  1 |    |    |    |    |    |    |    |    |    |    |    |
>> | 201412 |    |    |    |    |  1 |    |    |    |    |    |    |    |    |
>> | 201505 |    |    |    |  1 |    |    |    |    |    |    |    |    |    |
>> | 201508 |    |    |    |    |    |    |    |    |  1 |    |    |    |    |
>> | 201512 |    |    |    |    |    |    |  1 |    |    |    |    |    |    |
>> | 201605 |    |    |    |    |    |    |    |    |    |    |    |    |    |
>> |--------+----+----+----+----+----+----+----+----+----+----+----+----+----|
>> |        |  8 |  5 |  9 |  3 |  4 | 15 |  1 |  6 |  2 | 13 |  9 |  6 |  7 |
>
> Two of the possible solutions:
>
> |   Date | AA | BB | CC | DD | EE | FF | GG | HH | II | JJ | KK | LL | MM |
> |      / | <> | <> | <> | <> | <> | <> | <> | <> | <> | <> | <> | <> | <> |
> |--------+----+----+----+----+----+----+----+----+----+----+----+----+----|
> | 201005 |    |    |    |    |  1 |    |    |  1 |    |    |    |  1 |    |
> | 201008 |    |    |    |  1 |    |    |    |    |    |    |    |    |    |
> | 201012 |    |    |    |    |    |    |    |    |    |    |    |    |    |
> | 201105 |    |    |    |    |    |  1 |    |    |    |    |    |    |    |
> | 201108 |    |    |    |    |    |    |  1 |    |    |    |    |    |    |
> | 201112 |    |    |    |    |    |    |    |    |    |  1 |    |    |    |
> | 201205 |    |    |    |    |    |    |    |    |    |    |    |    |    |
> | 201208 |    |    |    |    |    |    |    |    |    |    |    |    |    |
> | 201212 |    |    |    |    |    |    |    |    |  1 |    |    |    |    |
> | 201305 |    |    |  1 |    |    |    |    |  2 |    |    |  1 |    |    |
> | 201308 |  1 |    |    |    |    |    |    |    |    |    |    |    |    |
> | 201312 |    |    |    |    |    |    |    |    |    |    |    |    |  1 |
> | 201405 |    |    |    |    |    |    |    |  1 |    |    |    |  1 |    |
> | 201408 |    |  1 |    |    |    |    |    |    |    |    |    |    |    |
> | 201412 |    |    |    |    |  1 |    |    |    |    |    |    |    |    |
> | 201505 |    |    |    |  1 |    |    |    |    |    |    |    |    |    |
> | 201508 |    |    |    |    |    |    |    |    |  1 |    |    |    |    |
> | 201512 |    |    |    |    |    |    |  1 |    |    |    |    |    |    |
> | 201605 |    |    |    |    |    |    |    |    |    |    |    |    |    |
> |--------+----+----+----+----+----+----+----+----+----+----+----+----+----|
> |        |  8 |  5 |  9 |  3 |  4 | 15 |  1 |  6 |  2 | 13 |  9 |  6 |  7 |
> #+TBLFM: @>$<<..@>$> = find(rev(@I..@II), 1) - 1; E
>
> Note that I moved the header separator line.
>
> When the last non-empty cell is not limited to be always 1 it gets a
> bit more complicated:
>
> #+TBLFM: @>$<<..@>$> = '(position-if-not (lambda (x) (equal x ""))
> (reverse '(@I..@II))); E
>
> Michael

  reply	other threads:[~2016-02-20 22:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-20 19:41 Table calculation Brett Presnell
2016-02-20 21:13 ` Michael Brand
2016-02-20 22:48   ` Brett Presnell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-12-10 19:32 Xiao-Yong Jin

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=87lh6fdmlu.fsf@ufl.edu \
    --to=presnell@member.fsf.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=michael.ch.brand@gmail.com \
    /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).