emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bernt Hansen <bernt@norang.ca>
To: "Daniel J. Sinder" <djsinder@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Including row numbers in a table
Date: Sat, 09 Aug 2008 02:57:48 -0400	[thread overview]
Message-ID: <87r68yu13n.fsf@gollum.intra.norang.ca> (raw)
In-Reply-To: <87vdyau3sm.fsf@gollum.intra.norang.ca> (Bernt Hansen's message of "Sat\, 09 Aug 2008 01\:59\:37 -0400")

Bernt Hansen <bernt@norang.ca> writes:

> "Daniel J. Sinder" <djsinder@gmail.com> writes:
>
>> I'd like to use a formula for the first column so that if I move rows
>> around using org commands, the row numbers can be easily
>> re-calculated.  Note that I'd like numbering to continue sequentially
>> across horizontal lines.
>>
>> I've tried column formulas like @-1+1, but the horizontal lines get in
>> the way.  And if every row needs it's own formula, it's hardly better
>> than just filling in the numbers.
>>
>> Can anyone suggest how to do this is a reasonably automated fashion?
>>
>
>
>   | Row | Data Column 1  | Data Column 2       |
>   |-----+----------------+---------------------|
>   |   1 | some data      | more data           |
>   |   2 | some more data | even more data      |
>   |-----+----------------+---------------------|
>   |   3 | and more       | that's all          |
>   |   4 | still more     | yup, you guessed it |
>   |-----+----------------+---------------------|
> #+TBLFM: $1=find(@I$2..@III$2,$2)
>
> This assumes the data in Data Column 1 ($2) is unique


This works better.  It doesn't assume anything about the data and you
can add as many horizontal lines as you want in the table.  This also
removes the requirement for the trailing horizontal line from the
previous solution.

  | Row | Data Column 1 | Data Column 2 |
  |-----+---------------+---------------|
  |   1 | x1            |               |
  |   2 | some data     | more data     |
  |-----+---------------+---------------|
  |   3 |               |               |
  |   4 |               |               |
  |   5 |               |               |
  |   6 |               |               |
#+TBLFM: $1=vlen(@I$2..0)/2;EN

-Bernt

  reply	other threads:[~2008-08-09  6:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-09  4:40 Including row numbers in a table Daniel J. Sinder
2008-08-09  5:59 ` Bernt Hansen
2008-08-09  6:57   ` Bernt Hansen [this message]
2008-08-09  7:04     ` Bernt Hansen
2008-08-09  8:16       ` Daniel J. Sinder

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=87r68yu13n.fsf@gollum.intra.norang.ca \
    --to=bernt@norang.ca \
    --cc=djsinder@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).