Hmm.. How is TRUNCATE(account, 3) different from ROOT(account, 3)? # Operations on accounts.
class Root(query_compile.EvalFunction): "Get the root name(s) of the account." __intypes__ = [str, int] def __init__(self, operands): super().__init__(operands, str) def __call__(self, context): args = self.eval_args(context) return account.root(args[1], args[0]) In accounts.py: def root(num_components, account_name): """Return the first few components of an account's name. Args: num_components: An integer, the number of components to return. account_name: A string, an account name. Returns: A string, the account root up to 'num_components' components. """ return join(*(split(account_name)[:num_components])) Thanks On Tuesday, September 18, 2018 at 1:28:07 PM UTC-5, Martin Blais wrote: > > Pull & update: > > https://bitbucket.org/blais/beancount/commits/c5057262f77d7b16fa2250b22f115e9ecee26754 > > bean-query $L 'select truncate(account, 3), convert(cost(sum(position)), > "USD") group by 1 order by 1' > > Also note the existence of the PARENT(), LEAF() and ROOT() functions to > act on account name strings. > Moreover, if you have mixed assets, you will want to convert or extract > the cost in order to view output that's manageable. > > > > > On Tue, Sep 18, 2018 at 10:29 AM Vikas Rawal <vikas...@gmail.com > <javascript:>> wrote: > >> I would like create a trial balance report with accounts truncated to a >> specific depth (say, two levels). >> >> How could I modify the following trial balance query to achieve this? >> >> SELECT account, sum(position) >> GROUP BY account >> ORDER BY account; >> >> >> Vikas >> >> -- >> 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+...@googlegroups.com <javascript:>. >> To post to this group, send email to bean...@googlegroups.com >> <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/beancount/CALtzAB280FQqE20Pdkoj%2B7FTa0GCXy8JfDuxmvaNS0Z7ExNGsA%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/beancount/CALtzAB280FQqE20Pdkoj%2B7FTa0GCXy8JfDuxmvaNS0Z7ExNGsA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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 post to this group, send email to beancount@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/2edcf0d0-5510-4523-aaa1-97c2658b6014%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.