Dear all,

I must I still struggle to find a way to use balance to calculate the net 
worth on  certain date (e,g, 2020-12-31 for my example from this thread)

It looks like the *balance *field does not respect the WHERE filter.

In this case, what is the purpose of the balance field all together?


On Sunday, June 2, 2024 at 2:29:23 PM UTC+2 Chary Ev2geny wrote:

> Dan,
>
> is it possible to get the result as in the 1st query, but using the *balance 
> *?
>
> account amount (EUR)
> Assets:Bank1 1000.0
> Assets:Bank2 1000.0
>
> On Sunday, June 2, 2024 at 12:36:23 AM UTC+2 [email protected] wrote:
>
>> On 01/06/24 21:27, Chary Chary wrote: 
>> > I am still trying to find the way to calculate the net worth at a 
>> > certain date using *balance *field (I am not sure it will give me any 
>> > advantage) 
>> > 
>> > But somehow it does not quire work as I expect 
>> > 
>> > E.g. 
>> > 
>> > ledger_text = """ 
>> > 
>> > 2020-01-01 open Assets:Bank1 
>> > 2020-01-01 open Assets:Bank2 
>> > 2020-01-01 open Income:Salary 
>> > 
>> > 2020-01-01 * "Salary 1" 
>> >   Income:Salary 
>> >   Assets:Bank1 1000 EUR 
>> > 
>> > 2020-01-20 * "Salary 2" 
>> >   Income:Salary 
>> >   Assets:Bank2 1000 EUR 
>> > 
>> > 2021-01-20 * "Salary 3" 
>> >   Income:Salary 
>> >   Assets:Bank2 1000 EUR 
>> > """ 
>> > 
>> > date_iso = datetime.date(2020,12,31).isoformat() 
>> > 
>> > query=f""" 
>> > select account, SUM(position) as amount 
>> > where date <= {date_iso}AND account ~ 'Assets|Liabilities' 
>> > """ 
>> > 
>> > result: 
>> > 
>> > account amount (EUR) 
>> > Assets:Bank1 1000.0 
>> > Assets:Bank2 1000.0 
>> > 
>> > 
>> > This is correct!! 
>> > Now using balance field 
>> > query=f""" 
>> > select account, LAST(balance) as amount 
>> > where date <= {date_iso}AND account ~ 'Assets|Liabilities' 
>> > """ 
>> > account amount (EUR) 
>> > Assets:Bank1 1000.0 
>> > Assets:Bank2 2000.0 <==== This is incorrect! 
>> > So, what am I doing wrong? 
>>
>> AFAICT, both queries do what they are expected to do. 
>>
>> 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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/beancount/5c2aa2ea-98c1-45ce-8e68-d941e23d6f23n%40googlegroups.com.

Reply via email to