Not sure it can be done in beanquery, but here is example how it can easily be done in pandas https://www.isabekov.pro/multiperiod-hledger-style-reports-in-beancount-pivoting-a-table/
In general it seems like using beanquery together with pandas in jupyter notebook is the best way forward for reporting out our beancount. in pandas you can do some other things, which are not available in beanquery: pivot by, add totals to columns and rows etc. Plus add plotting with matplotlib - what else do you need? On Saturday, March 11, 2023 at 8:28:39 PM UTC+1 Daniel González wrote: > Hi, > I'm generating an income statement (with only my expenses) like this: > > SELECT account, sum(position) FROM OPEN ON 2023-03-01 CLOSE ON 2023-03-30 > WHERE account ~ "Expenses" GROUP BY 1 ORDER BY 1 > > But I have some subdivisions of my accounts that I would like to report > one level up. > > For example, now I get the following output: > > ... > Expenses:Gifts:JohnDoe 50 USD > Expenses:Gifts:JaneDoe 25 USD > ... > > And I would like to have: > > ... > Expenses:Gifts 75 USD > ... > > Is there a way to aggregate the accounts using beanquery? > > Thank you. > -- 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 beancount+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/f8402209-ce27-48cc-9948-dc194f3b0a9an%40googlegroups.com.