Filtering on balance and relative dates

11 views
Skip to first unread message

Keith Edmunds

unread,
Jul 31, 2021, 5:02:04 AMJul 31
to hledger
I want to run a report that will show whether my bank balance will fall below a pre-determined level in the near future.

If I run

hledger balance acct:assets -D -b today -e 2021-08-30 --forecast --cumulative

...then I get 30 columns of data, which is a bit much.

  1. Can I filter the report to only show balances below, say, 500?
  2. I can have '-b today', but is there a way of having a relative end date, such as '-e today+30'?

Simon Michael

unread,
Jul 31, 2021, 3:08:15 PMJul 31
to hledger
> If I run
>
> hledger balance acct:assets -D -b today -e 2021-08-30 --forecast --cumulative
>
> ...then I get 30 columns of data, which is a bit much.

In general --historical will show your bank balance here, not --cumulative.

You can add --transpose, making it tall rather than wide:

hledger balance acct:assets -D -b today -e 2021-08-30 --forecast --historical --transpose

Or you could use register:

hledger reg assets -b today -e 2021-08-30 --forecast --historical

Or aregister (which is always --historical):

hledger areg assets -b today -e 2021-08-30 --forecast

Aside: just for the record I will mention two issues I noticed:

1. Those reg/areg commands show 2021-08-28 as last item, ie 2 days
before the -e date (tested back to 1.20). I expected 2021-08-29.

2. The bal command does the same thing in 1.20. And since 1.21 it
displays up to 2021-08-29, but the forecasted transactions still
end on 2021-08-28 (causing the last two days to show the same
balance, in my test).

> Can I filter the report to only show balances below, say, 500?

No, you can't query by the running balance in hledger, currently.
You could probably achieve it by filtering the output with grep.

> I can have '-b today', but is there a way of having a relative end date, such as '-e today+30'?

Also no, alas. You can approximate it: -e nextmonth, -e nextquarter

Otherwise use your shell, eg in bash: -e `date -I -d today+30days`


Simon Michael

unread,
Jul 31, 2021, 3:49:51 PMJul 31
to hledger


On Jul 31, 2021, at 9:08 AM, Simon Michael <si...@joyful.com> wrote:
Aside: just for the record I will mention two issues I noticed:

(More notes coming to the issue tracker later.)
Reply all
Reply to author
Forward
0 new messages