Querying transactions based on multiple accounts (from accountA to accountB)

68 views
Skip to first unread message

Ankur Sinha

unread,
Jun 12, 2023, 5:04:27 PM6/12/23
to ledge...@googlegroups.com
Hi folks,

I'm looking for a way to list/filter transactions based on multiple
accounts. For example, I'd like to see transactions where money moved
from Account A to Account B (or vice versa).

I found this post, but it doesn't quite work for me. It gives various
errors related to the dates/year field:

https://money.stackexchange.com/questions/154316/how-can-i-identify-all-transfers-from-account-a-to-account-b-in-ledger-cli

I thought perhaps an `and` query would work: `Account A and Account B`;
but that still seems to list all transactions in with either `Account A`
or `Account B` are used (like an "or" query?).

Any pointers would be most appreciated (even to the docs :))

$ ledger --version
Ledger 3.2.1-20200518, the command-line accounting tool

Copyright (c) 2003-2019, John Wiegley. All rights reserved.

This program is made available under the terms of the BSD Public License.
See LICENSE file included with the distribution for details and disclaimer.

--
Thanks,
Regards,
Ankur Sinha "FranciscoD" (He / Him / His) | https://fedoraproject.org/wiki/User:Ankursinha
Time zone: Europe/London
signature.asc

Martin Michlmayr

unread,
Jun 12, 2023, 5:09:36 PM6/12/23
to sanjay...@gmail.com, ledge...@googlegroups.com
* Ankur Sinha <sanjay...@gmail.com> [2023-06-12 22:04]:
> I'm looking for a way to list/filter transactions based on multiple
> accounts. For example, I'd like to see transactions where money moved
> from Account A to Account B (or vice versa).

ledger bal Assets:A -l "any(account =~ /Assets:B/)"

--
Martin Michlmayr
https://www.cyrius.com/

Ankur Sinha

unread,
Jun 13, 2023, 4:04:20 AM6/13/23
to Martin Michlmayr, ledge...@googlegroups.com
On Mon, Jun 12, 2023 23:09:31 +0200, Martin Michlmayr wrote:
> * Ankur Sinha <sanjay...@gmail.com> [2023-06-12 22:04]:
> > I'm looking for a way to list/filter transactions based on multiple
> > accounts. For example, I'd like to see transactions where money moved
> > from Account A to Account B (or vice versa).
>
> ledger bal Assets:A -l "any(account =~ /Assets:B/)"

Works like a charm. Thanks Martin!
signature.asc
Reply all
Reply to author
Forward
0 new messages