hledger icon indicating copy to clipboard operation
hledger copied to clipboard

A wish for an "average-only" report

Open amybailey opened this issue 6 years ago • 5 comments

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

amybailey avatar Apr 20 '19 14:04 amybailey

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.

simonmichael avatar Apr 20 '19 16:04 simonmichael

Would adding -T/--total still be allowed ?

simonmichael avatar Apr 20 '19 16:04 simonmichael

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?

amybailey avatar Apr 21 '19 16:04 amybailey

I think --format isn't supported with multicolumn reports.

simonmichael avatar Apr 21 '19 16:04 simonmichael

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.

hiqua avatar Aug 04 '21 20:08 hiqua