Thanks! I have questions:

On Oct 2, 2014, at 7:18 PM, Erik Hetzner <[email protected]> wrote:
> 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.

I'm confused by the "monthly" - my guess it is has no effect in these ledger 
balance commands ?

> 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

Nifty, could you explain the divisor expression a little more ? I don't quite 
understand how it's working.

> 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.

Right, I forgot to mention "8. the average you want is the last number in the 
running total column".

> 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

You might get a better result if you say --depth 3, the depth of your account 
of interest. IIRC I improved the aggregation of depth-clipped postings in 
hledger register.

Best
-Simon

-- 

--- 
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.

Reply via email to