Hi Simon,
At Thu, 02 Oct 2014 11:50:41 -1000,
Simon Michael wrote:
>
> Far from it - everyone wants this sooner or later. When we discussed
> this on #ledger in July, my answer was:
>
> ledger reg -MAE '^some:account$' --depth 2
>
> 1. for each account you're interested in, one at a time
> 2. limiting the report depth to that of the account
> (to get a single report line per period)
> 3. ^ and $ to ensure precise account matching
> 4. -E to show per-period average not per-line average
> 5. -M for monthly, -W for weekly etc.
> 6. ledger 3 (or hledger), not ledger 2
> 7. with current ledger 3, ensure there's some data (maybe in each
> period ?) to avoid a segfault bug
>
> Does the more complicated command you gave have advantages ? Maybe it
> shows all accounts at once ? I don't have a ledger-compatible journal
> here that avoids 7, so sample output would be nice to see.
Sure, here Is an example. This is one expense account:
$ ledger bal ^Expenses:Erik:Bicycle -E -p "monthly from 2014 until last month"
$267.64 Expenses:Erik:Bicycle
That is my total bike spending in 2014. The number I am looking for is
$267.64 / 9 => $29.74, my average monthly spending in 2014 (until
Sept) on bike expenses. So this command gives me what I am looking
for:
$ ledger bal ^Expenses:Erik:Bicycle -E -p "monthly from 2014 until last month"
--display-total "(display_total>0 or display_total<0) ?
display_total/(to_int(format_datetime(d, '%m')) - 1) : ''"
$29.74 Expenses:Erik:Bicycle
Moreover, if I don't restrict it to that one account, it works for all
accounts, giving me my average monthly spending in each expense
category for the year.
Your command gives me:
$ hledger reg -MAE '^expenses:erik:bicycle$' --depth 2 -p "monthly from 2014
until last month"
2014/01/01 - 2014/01/31 Expenses:Erik $22.00
$22.00
2014/02/01 - 2014/02/28 Expenses:Erik $23.07
$22.54
2014/03/01 - 2014/03/31 Expenses:Erik $37.24
$27.44
2014/04/01 - 2014/04/30 Expenses:Erik $157.00
$59.83
2014/05/01 - 2014/05/31 0
$47.86
2014/06/01 - 2014/06/30 0
$39.89
2014/07/01 - 2014/07/31 Expenses:Erik $28.33
$38.23
2014/08/01 - 2014/08/31 0
$33.46
2014/09/01 - 2014/09/30 0
$29.74
which does give me the right answer at the end ($29.74) but outputs a
lot more and only works on one account. ledger doesn't seem to work
properly:
$ ledger reg -MAE '^expenses:erik:bicycle$' --depth 2 -p "monthly from 2014
until last month"
14-May-01 - 14-May-31 <None> 0
$47.86
14-Jun-01 - 14-Jun-30 <None> 0
$39.88
Maybe what I am looking for is strange, but for me it makes sense.
best, Erik
--
Sent from my free software system <http://fsf.org/>.
--
---
You received this message because you are subscribed to the Google Groups
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.