Hello, I was wondering whether anyone would b...

(Evyve) #1

Hello, I was wondering whether anyone would be able to help me understand an odd number behaviour in my app… Namely sums of 2-decimal numbers gain multiple decimals (probably due to rounding errors) in a pie chart view. Attached are two screenshots illustrating this.

My app is about expenses. The ‘expense’ column is of type ‘Decimal’ (not ‘Price’) and set to 2 decimals. Each ‘expense’ belongs to a ‘category’ and a ‘subcategory’ (2 other columns) on a given ‘Date’.

I’ve attached an example of aggregated pie chart obtained for the category ‘Vacances’ that shows all subcategories of that one category (e.g. food, transport…). The other screenshot shows all amounts registered again ‘Vacances > Restaurant’, i.e. the red pie slice with a total of -112.14999999999. Why isn’t the total 112.15 ?

Thanks in advance for any help with this :slight_smile: !

(Evyve) #2

And just for completion, if the ‘expense’ type is ‘Price’, it’s the same issue.

(Evyve) #3

I’m wondering whether this is because the default number format is %, which would involve computing the sum across all categories (or subcategories) and a division. That value is then converted back to a “number” when the user asks for values rather than percentages… (?).