Issue #160: Is it possible to combine the "balance" column with aggregate functions? (blais/beancount)

67 views
Skip to first unread message

Jonatan Kornholt

unread,
Mar 3, 2017, 12:58:48 PM3/3/17
to bean...@googlegroups.com
New issue 160: Is it possible to combine the "balance" column with aggregate functions?
https://bitbucket.org/blais/beancount/issues/160/is-it-possible-to-combine-the-balance

Jonatan Kornholt:

I have tried to create a beancount-query to show the increase in net worth per month and the total net worth in one query. But it doesn't seem like I can combine the sum function with the balance function:

SELECT year(date) as year, month, sum(value(position)) as NetIncrease, balance as NetWorth
WHERE account ~ 'Assets|Liabilities'
AND not account ~ 'Pension'
GROUP BY year, month
ORDER by year, month

This returns:

> "All non-aggregates must be covered by GROUP-BY clause in aggregate query."

If I then add:

GROUP BY year, month, NetWorth

Then the Fava website returns:

> "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."

I first posted this issue in bean-count-sql-queries and aumayr suggested I posted here instead. He also supplied the following stacktrace:

```
#!python

Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/cmd.py", line 214, in onecmd
func = getattr(self, 'do_' + cmd)
AttributeError: 'QueryShell' object has no attribute 'do_SELECT'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/dominik/Projects/beancount/beancount/src/python/beancount/query/shell.py", line 258, in run_parser
self.dispatch(statement)
File "/Users/dominik/Projects/beancount/beancount/src/python/beancount/query/shell.py", line 238, in dispatch
return method(statement)
File "/Users/dominik/Projects/beancount/fava/fava/core/query_shell.py", line 83, in on_Select
self.options_map)
File "/Users/dominik/Projects/beancount/beancount/src/python/beancount/query/query_execute.py", line 288, in execute_query
store = agg_store[row_key]
TypeError: unhashable type: 'Inventory'
```

Is it possible to combine sum and balance to produce the result I want?


victora...@gmail.com

unread,
Mar 6, 2017, 12:53:58 PM3/6/17
to Beancount, issues...@bitbucket.org
I just tried to do a query very similar to yours today and had the same issue... Anyone knows if it is possible?
Reply all
Reply to author
Forward
0 new messages