Summation for super-accounts in bean-report

210 views
Skip to first unread message

Dan Andersson

unread,
Dec 21, 2023, 5:38:24 AM12/21/23
to Beancount
Hi,

Example bean-report output:

Expenses:Test:Foo     2 USD
Expenses:Test:Foo     4 USD

How can I automatically show summations for all super-accounts? For example

Expenses                             6 USD
Expenses:Test                    6 USD
Expenses:Test:Foo     2 USD
Expenses:Test:Foo     4 USD

Thanks,
Dan

Martin Michlmayr

unread,
Dec 21, 2023, 5:51:57 AM12/21/23
to bean...@googlegroups.com
bean-report is deprecated.

You can do the following in bean-query:

SELECT PARENT(account), position, balance WHERE account ~ 'Expenses:Test:'

you can also use PARENT(PARENT(account))

This is for register report. For balance report, something like that:

SELECT PARENT(account), SUM(position) WHERE account ~ 'Expenses:Test:' GROUP BY PARENT(account)

(There might be more elegant ways of doing this, but the queries above
work for me.)

Martin


* Dan Andersson <danande...@gmail.com> [2023-12-21 02:38]:
> --
> You received this message because you are subscribed to the Google
> Groups "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [1]beancount+...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/beancount/ff1ad476-8e0c-4cd2-ac1c-
> 4eec19af8554n%40googlegroups.com.
>
> References
>
> 1. mailto:beancount+...@googlegroups.com
> 2. https://groups.google.com/d/msgid/beancount/ff1ad476-8e0c-4cd2...@googlegroups.com?utm_medium=email&utm_source=footer

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

Message has been deleted

Chary Chary

unread,
Dec 21, 2023, 7:01:52 AM12/21/23
to Beancount
I tend to use beancount and beanquery to extract interesting data and to do further processing in pandas in Jupyter Notebook,  where data processing and visualization tools are very developed.

https://www.isabekov.pro/multiperiod-hledger-style-reports-in-beancount-pivoting-a-table/

I think what you are asking for is effectively pivot table subtotals. This can be done pandas

Red S

unread,
Dec 23, 2023, 12:48:00 AM12/23/23
to Beancount
Nice. What would be terrific is if this workflow (query -> pandas -> Jupyter + Visualization) got integrated seamlessly into Fava.

Chary Chary

unread,
Dec 24, 2023, 6:38:10 AM12/24/23
to Beancount
Fava is a great tool, but so far I haven't found what extra would I get to what I have already in my setup:

I am using VScode to enter beancount ledger as well as to run Jupyter notebook with all the queries and visualizations in it.

As I said, data processing and visualization is so developed in pandas + matplotlib  + Jupyter invironment, that it is hard to beat it.

Martin Michlmayr

unread,
Jan 2, 2024, 2:34:02 AM1/2/24
to bean...@googlegroups.com, dan...@grinta.net
I just noticed one problems with the use of PARENT(). This assumes
that all of your accounts have the same depth.

It might be better to use something like splitcomp(account, ":", 1).
This will give "Foo" for both Expenses:Foo:Bar and Expenses:Foo

Whereas PARENT(account) would give Expenses:Foo for the first and
Expenses for the latter.

(Daniele, is there a nicer way than splitcomp(account, ":", 1)?
Getting a particular subaccount seems pretty common. Also, I
couldn't figure out a way to extract 2 subaccounts - Expenses:Foo:Bar
should yield Expenses:Foo and Expenses:Foo should also yield
Expenses:Foo; is that possible?)




* Martin Michlmayr <t...@cyrius.com> [2023-12-21 18:51]:

Chary Chary

unread,
Jan 2, 2024, 6:44:52 AM1/2/24
to Beancount


(Daniele, is there a nicer way than splitcomp(account, ":", 1)?
Getting a particular subaccount seems pretty common. Also, I
couldn't figure out a way to extract 2 subaccounts - Expenses:Foo:Bar
should yield Expenses:Foo and Expenses:Foo should also yield
Expenses:Foo; is that possible?)


Reply all
Reply to author
Forward
0 new messages