On 11/03/23 20:27, 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?
SELECT
root(account, 2),
sum(position)
FROM ...
WHERE
root(account, 1) = 'Expenses'
GROUP BY 1
ORDER BY 1
This aggregates all accounts to the second account name component, like
in your example. This requires that your account name structure is
somehow regular, if it is not, there is no way of doing what you want
with bean-query only.
Cheers,
Dan
--
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/d7f522c4-0ce3-cd1b-4945-3b689392abb8%40grinta.net.