From: Darlan Cavalcante Moreira <darcamo@gmail.com>
To: Johan Ekh <ekh.johan@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Tag table entries?
Date: Wed, 05 May 2010 11:27:44 +0200 [thread overview]
Message-ID: <4be13a0f.0f67f10a.3411.7b8e@mx.google.com> (raw)
In-Reply-To: <t2i417457b51005040735rf704db01g1f543ebfc687438a@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 402 bytes --]
The snippet is attached.
In my case I call the snippet inside a 2-level heading (also using odd
number of start for each level) and you will probably want to modify the
snippet to your needs.
The snippet only asks the name of the current month, the current year and
the name of the last month. I suppose this could be completely automatic if
you know how to get this information with lisp.
Darlan
[-- Attachment #2: expenses --]
[-- Type: application/octet-stream, Size: 6518 bytes --]
#name : expenses
# contributor: Darlan Cavalcante Moreira
# --
$0***** ${1:Month} ${2:Year}
Org speed keys is your friend to navigate the headlines
******* Food
Expenses with food (not including groceries)
#+TBLNAME: Food$1$2
| | *Local* | *Date* | *Value* |
|---+---------+---------+---------|
| | Lunch | | 0.00 |
| | Coffee | | 0.00 |
|---+---------+---------+---------|
| # | | *Total* | 0.00 |
#+TBLFM: @4\$4=vsum(@2..@-1);%.2f
******* Bills
#+TBLNAME: Bills$1$2
| | *Bill* | *Date* | *Value* |
|---+--------------------------+--------+---------|
| | Health Insurance | | 0.00 |
| | Cell Phone | | 0.00 |
| | Something else | | 0.00 |
| # | Credit Card (last month) | | |
|---+--------------------------+--------+---------|
| # | *Total* | | 0.00 |
#+TBLFM: @5\$4=remote(CreditCard${3:Last month}$2,\$LR4);%.2f::@6\$4=vsum(@2\$4..@-1\$4);%.2f
******* Entertainment
#+TBLNAME: Entertainment$1$2
| | *Type* | *Date* | *Value* |
|---+---------+--------+---------|
| | Movies | | 0.00 |
| | etc | | 0.00 |
|---+---------+--------+---------|
| # | *Total* | | 0.00 |
#+TBLFM: @4\$4=vsum(@2..@-1);%.2f
******* Transport
#+TBLNAME: Transport$1$2
| | *Type* | *Date* | *Valor* |
|---+--------------+--------+---------|
| | Fuel | | 0.00 |
| | Bus ticket | | 0.00 |
| | Train ticket | | 0.00 |
|---+--------------+--------+---------|
| # | *Total* | | 0.00 |
#+TBLFM: @5\$4=vsum(@2..@-1);%.2f
******* Miscellaneous
Whatever does not fit the other categories
#+TBLNAME: Miscellaneous$1$2
| | *Type* | *Date* | *Value* |
|---+---------+--------+---------|
| | FNAC | | 0.00 |
|---+---------+--------+---------|
| # | *Total* | | 0.00 |
#+TBLFM: @3\$4=vsum(@2..@-1);%.2f
******* Groceries
I like to put each item here and separate the dates with hlines.
If an item cost according to weight I put the weight in the
"Quantity" and the cost/kg in the "Cost per unit"
#+TBLNAME: Groceries$1$2
| | *Date* | *Item* | *Quantity* | *Cost per unit* | *Payed* |
|---+--------+--------+------------+-----------------+---------|
| # | Date1 | item | 0 | 0.00 | 0.00 |
| # | | item | 0.00 | 0.00 | 0.00 |
|---+--------+--------+------------+-----------------+---------|
| # | Date2 | item | 0.0 | 0.00 | 0.00 |
|---+--------+--------+------------+-----------------+---------|
| # | | | | | 0.00 |
#+TBLFM: \$6=\$4*\$5;%.2f::@5\$6=vsum(@2..@-1);%.2f
******* Total of expenses in the month
The table here concatenates the results from all of the other
tables. Update the table with C-u C-u C-c *
#+TBLNAME: Expenses$1$2
#+PLOT: ind:2 deps:(4) with:histograms
| | *Category* | *Value* |
|---+----------------+---------|
| # | Entertainment | |
| # | Bills | |
| # | Food | |
| # | Transport | |
| # | Miscellaneous | |
| # | Groceries | |
|---+----------------+---------|
| # | *Total* | |
| # | Total + Credit | |
#+TBLFM: @2\$3=remote(Entertainment$1$2,\$LR4);%.2f::@3\$3=remote(Bills$1$2,\$LR4);%.2f::@4\$3=remote(Food$1$2,\$LR4);%.2f::@5\$3=remote(Transport$1$2,\$LR4);%.2f::@6\$3=remote(Miscellaneous$1$2,\$LR4);%.2f::@7\$3=remote(Groceries$1$2,\$LR6);%.2f::@8\$3=vsum(@2\$3..@-1);%.2f::@9\$3=@-1+remote(CreditCard$1$2,\$LR4);%.2f
Use C-c C-c to run the code below (requires org-babel and gnuplot)
#+BEGIN_SRC gnuplot :var data=Expenses$1$2[1:-3] :var summation=Expenses$1$2[9,2] :results silent :exports none
reset
set key off
set title "Expenses de $1 $2"
set xtics nomirror rotate by -10
plot data using 3:xticlabels(2) with histograms
set label "Max in a single category: %.2f",GPVAL_Y2_MAX at graph 0.03, graph 0.93
set label "Total: %.2f",summation at graph 0.03, graph 0.88 textcolor rgbcolor "red"
#+END_SRC
******* Credit Cards Expenses
Expenses with Credit Card will not be counted in this month
expenses but in the next one.
However, the total expenses table also has "Total + Credit" that
included the expenses with the credit card for the current month.
Since international expenses with the credit card are in dollar I
use the constant *DolarParaReal* to convert from dollar to
Brazilian Reais in order to have the total spent with credit
card. I update this constant each month when I know the correct
value used by the bank for the month.
#+CAPTION: Expenses using credit card in $1-$2
#+TBLNAME: CreditCard$1$2
| | *Date* | *Purchase* | *Value* | *Valor (\$)* |
|----+--------+----------------------------------+---------+--------------|
| | | item | 0.00 | 0.00 |
| | | item | 0.00 | 0.00 |
|----+--------+----------------------------------+---------+--------------|
| \$ | | DolarParaReal=1.718 | | |
| # | | *Total in each currency* | 0.00 | 0.00 |
| # | | *Total (in reais)* | 0.00 | 0.00 |
|----+--------+----------------------------------+---------+--------------|
| # | | *Sum of the expenses (in reais)* | 0.00 | |
#+TBLFM: @5\$4=vsum(@2..@-1);%.2f::@5\$5=vsum(@2..@-1);%.2f::@6\$4=@5\$4;%.2f::@6\$5=@5\$5*\$DolarParaReal;%.2f::@7\$4=@-1\$4+@-1\$5;%.2f
[-- Attachment #3: Type: text/plain, Size: 4370 bytes --]
At Tue, 4 May 2010 16:35:07 +0200,
Johan Ekh <ekh.johan@gmail.com> wrote:
>
> [1 <multipart/alternative (7bit)>]
> [1.1 <text/plain; ISO-8859-1 (7bit)>]
> That sounds very good! This is the functionality I am looking for!
> Would you like to share your yasnippet and any other settings that you have
> worked out?
> It would help me alot!
>
> Thanks!
>
> Johan
>
> On Tue, May 4, 2010 at 10:36 AM, Darlan Cavalcante Moreira <
> darcamo@gmail.com> wrote:
>
> >
> > For that I just use separate tables. I use a headline for each month, say
> > "May 2010" and subheadings for each category (groceries, bills, transport,
> > etc.) with a corresponding table in each one. Each table calculates the
> > total for that category and has a unique name, say "BillsMay2010".
> >
> > All of the totals for each table are concatenated in a table
> > "ExpensesMay2010" (also in a subheadings of the month headline) that has
> > one line for each category and calculates the total. There is even gnuplot
> > code with org-babel to plot the amount spent in each category from the
> > "ExpensesMay2010" table.
> >
> > Of course there is a snippet (with yasnippet) for all of this and in the
> > first day of the month I call the snippet and only provide the month name
> > and the year (both used to make the name of each table unique). This
> > snippet makes easy creating all the infrastructure for each month and org
> > speedkeys makes easy navigating the categories to quickly add
> > something.
> >
> > This works very well and I only need to be careful and update each table
> > (C-u C-u C-c *) when I make some change.
> >
> > Darlan
> >
> > At Tue, 4 May 2010 08:36:05 +0200,
> > Johan Ekh <ekh.johan@gmail.com> wrote:
> > >
> > > Thanks Dan!
> > > My idea was to go through a long imported table and quickly categorize
> > the
> > > different rows
> > > into a number of predefined categories, without having to actually type
> > the
> > > category for
> > > each row. Can I do that?
> > >
> > > If babel is a way, I think I would prefer to use python as I am familiar
> > > with it. But I have not used
> > > it with babel, is that possible?
> > >
> > > Best regards,
> > > Johan
> > >
> > >
> > > On Mon, May 3, 2010 at 10:52 PM, Dan Davison <davison@stats.ox.ac.uk>
> > wrote:
> > >
> > > > Johan Ekh <ekh.johan@gmail.com> writes:
> > > >
> > > > > Hi all,
> > > > > I wonder if it is possible to tag rows in a table?
> > > > >
> > > > > For example, if I have a table of expenses, i.e. columns with
> > "date",
> > > > "note" and "sum",
> > > > > and then want to group the entries into different categories such as
> > > > "groceries", "car" etc.
> > > > >
> > > > > Can I do this someway?
> > > >
> > > > Hi Johan,
> > > >
> > > > You can't attach metadata such as tags to table rows. Two things come
> > to
> > > > mind.
> > > >
> > > > 1. If you just want the table for visual purposes (as opposed for doing
> > > > calculations with it), then you could use column-view. I.e. you would
> > > > have a subtree for groceries and a subtree for car; categories such
> > > > as date, note and sum would be stored in properties.
> > > >
> > > > http://orgmode.org/manual/Column-view.html#Column-view
> > > >
> > > > Visibility cycling works in column view so you can group and ungroup
> > the
> > > > rows.
> > > >
> > > > [is there anyway of creating a normal Org table from a column view
> > > > "table"?]
> > > >
> > > > 2. org-babel: If you're happy with a suitable supported language, then
> > > > store the category label in a column and you can transform the master
> > > > table however you want. R would be a convenient language for working
> > > > with a table like this.
> > > >
> > > > Dan
> > > >
> > > >
> > > >
> > > > >
> > > > > Best regards,
> > > > > Johan
> > > > >
> > > > > _______________________________________________
> > > > > Emacs-orgmode mailing list
> > > > > Please use `Reply All' to send replies to the list.
> > > > > Emacs-orgmode@gnu.org
> > > > > http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> > > >
> >
> [1.2 <text/html; ISO-8859-1 (quoted-printable)>]
>
> [2 <text/plain; us-ascii (7bit)>]
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[-- Attachment #4: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2010-05-05 9:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-03 20:19 Tag table entries? Johan Ekh
2010-05-03 20:52 ` Dan Davison
2010-05-04 6:36 ` Johan Ekh
2010-05-04 8:36 ` Darlan Cavalcante Moreira
2010-05-04 14:35 ` Johan Ekh
2010-05-05 9:27 ` Darlan Cavalcante Moreira [this message]
2010-05-05 18:29 ` Johan Ekh
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=4be13a0f.0f67f10a.3411.7b8e@mx.google.com \
--to=darcamo@gmail.com \
--cc=ekh.johan@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).