hledger
hledger copied to clipboard
A wish for an "average-only" report
There are a (admittedly few) times when I want to see only the average balance of an account over some interval. For example when estimating a monthly budget amount for expenses, or bringing printed data to show a financial advisor, or just when the width of a report is unwieldy.
One possible implementation could be to add an --average-only option. This option would only make sense when using one of the interval options -D, -W, -M, -Q, or -Y
Output might look something like this:
$ hledger balance expenses:utilities -M --average-only --flat --drop 2
Average Monthly Balance yyyy/mm/dd-yyyy/mm/dd
|| Average
============++=============
electric || $128.63
naturalgas || $55.88
phone || $78.59
trash || $11.72
water || $63.33
------------++-------------
|| $338.15
That looks pretty good.
--average & --average-only would be mutually exclusive, and we'd describe them that way and give an error if both are used ? Or (simpler, preferred): the last one on the command line wins.
--average-only would be available on all the commands that currently support --average.
Would adding -T/--total still be allowed ?
Thinking about this more, this request is really just an output modifier. Perhaps it doesn't justify a new command line option but rather an %(average) field in --format string?
I think --format isn't supported with multicolumn reports.
FYI: A way to do this with https://github.com/BurntSushi/xsv
hl b -S -MA -O csv | xsv select Account,Average | xsv fmt -t '\t' | column -t
Does not work well with multiple currencies.