Why is bean-query rounding to 1 decimal place?

58 views
Skip to first unread message

CD

unread,
Sep 4, 2025, 7:46:59 AMSep 4
to Beancount
Prior to today I have mostly used fava to do queries but have been experimenting more with the command line.

For some reason all of my output in the command line is rounded to 1 decimal place even though the actual transactions have two decimal places.  This doesn't happen when I run queries from python scripts.

How do I fix that?  (I have searched the forum and asked Gemini and other AI and none have given me a useful answer).

Here's some output....

          account                 SUM(posit
------------------------------------  ---------
Expenses:General:Tractor:Maintenance  166.9 USD
Expenses:General:FieldMaintenance     380.0 USD

The actual amounts in the Beancount file are $166.87 and $379.99

Here's one of the transactions...

2025-08-21 ! "Amazon"
  Assets:Checking                 -379.99 USD
  Expenses:General:FieldMaintenance   379.99 USD


and when I get a total of the two transactions.

SUM(posit
---------
546.9 USD


Please advise.

Daniele Nicolodi

unread,
Sep 4, 2025, 12:51:21 PMSep 4
to bean...@googlegroups.com
On 04/09/25 13:46, CD wrote:
> Prior to today I have mostly used fava to do queries but have been
> experimenting more with the command line.
>
> For some reason all of my output in the command line is rounded to 1
> decimal place even though the actual transactions have two decimal
> places.

This is not the intended behavior.

When formatting a table, beanquery rounds the numerical values in
columns of type `position` to the most common number of decimal digits
for the values in the column. `sum(position)` has type `inventory` but
the same applies for each currency in the inventory.

Therefore, the only explanation for the behavior you observe, is that
the most common number of decimal digits for the values to be displayed
is 1 and not 2.

You do not provide enough information to help you further. For this we
would need the exact query you are running and a minimum ledger that
results in the problem you describe.

> This doesn't happen when I run queries from python scripts.

The table formatting code is only used when displaying results via the
beanquery shell.

Cheers,
Dan

CD

unread,
Sep 4, 2025, 2:30:04 PMSep 4
to Beancount
Thanks Dan.

I figured it out.  There were a lot of entries where there was only one decimal place.  ie - 54.8 USD   100.0 USD etc.  (1500 entries).

I changed all of those to two decimals and the bean-query results now show two decimal places.

Why would Beancount do that though?  If the items it brings up have two decimal points worth of information why would it truncate that?  I would understand if ALL of the transactions had one decimal point but it doesn't make sense for transactions that do have two decimal points of data.   I'm clearly not understanding something here.

-Chris

Martin Blais

unread,
Sep 4, 2025, 8:22:52 PMSep 4
to bean...@googlegroups.com
- It doesn't truncate it only displays them that way, all numbers are preserved
- Why does it use the most frequent? it's trying to guess what the right thing to do is
- I've been wanting to add a fixed option for a VLT, even had a shot at this a few months ago, but then I moved and got into something else and it got lost (it's easily the top one thing I would fix if I had the time)

If the AGI can finally come already and take away the entire economy with it and make my skills worthless I'll have a lot of time to fix Beancount
Ok later for now





--
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.
To view this discussion visit https://groups.google.com/d/msgid/beancount/06d75128-3345-42a7-9899-1c679e55d010n%40googlegroups.com.

Daniele Nicolodi

unread,
Sep 6, 2025, 12:48:27 PMSep 6
to bean...@googlegroups.com
On 05/09/25 02:22, Martin Blais wrote:
> - It doesn't truncate it only displays them that way, all numbers are
> preserved
> - Why does it use the most frequent? it's trying to guess what the right
> thing to do is
> - I've been wanting to add a fixed option for a VLT, even had a shot at
> this a few months ago, but then I moved and got into something else and
> it got lost (it's easily the top one thing I would fix if I had the time)

This has been on my mind for a while too. The implementation is not very
complex, but I didn't find a nice way to expose the functionality other
than having a global setting, but the user is likely to want to control
this per column, and in the case of inventory columns, even per currency.

What kind of interface did you have in mind?

Cheers,
Dan

Reply all
Reply to author
Forward
0 new messages