Bug 479887 - Incorrekt average in Reports
Summary: Incorrekt average in Reports
Status: RESOLVED NOT A BUG
Alias: None
Product: skrooge
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: 25.1.0
Assignee: Stephane MANKOWSKI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-16 11:53 UTC by Fabiano Caruana
Modified: 2025-11-20 19:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
screenshot Report (26.12 KB, image/png)
2024-01-16 11:53 UTC, Fabiano Caruana
Details
My average in Libreoffice calc (23.54 KB, image/png)
2024-05-03 15:40 UTC, Fabiano Caruana
Details
Periods with zero values (266.09 KB, image/png)
2025-10-12 10:46 UTC, Fabiano Caruana
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fabiano Caruana 2024-01-16 11:53:18 UTC
Created attachment 164943 [details]
screenshot Report

SOFTWARE/OS VERSIONS
Skrooge 2.31.0

Linux/KDE Plasma: opensuse Leap 15.5
(available in About System)
KDE Plasma Version:  5.27.9
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8

Hi Stephane,

I've been "playing" with skrooge since last month. I have taken my data from KMyMoney. I had to correct some data, but now everything is OK and I'm currently using KMyMoney and Skrooge in parallel.
The bank import with Aqbanking also works. Once I have everything under control, I check all the functions again.

But what was immediately noticeable:
Reports calculate the average incorrectly. For example, for 3 months, the average is calculated as 4 months. The two partial months at the beginning and end are used as a full month.

Category 2023-10 2023-11 2023-12 2024-01 Total Average *** correct average (for 3 months)
Output -61.58€ -82.58€ -114.96€ -63.78€ -322.90€ -80.72€ -107.63
Total -61.58€ -82.58€ -114.96€ -63.78€ -322.90€ -80.72€ -107.63

Period: October 17, 2023 to January 16, 2024

(see attachment)

greetings
Udo
Comment 1 Stephane MANKOWSKI 2024-05-02 11:00:55 UTC
(In reply to Fabiano Caruana from comment #0)
> Category 2023-10 2023-11 2023-12 2024-01 Total Average *** correct average
> (for 3 months)
> Output -61.58€ -82.58€ -114.96€ -63.78€ -322.90€ -80.72€ -107.63
> Total -61.58€ -82.58€ -114.96€ -63.78€ -322.90€ -80.72€ -107.63
> 
> Period: October 17, 2023 to January 16, 2024
> greetings
> Udo
Hi,
This is the expected behavior.
Indeed, the average and the tendency curve are computed by using the values of the table.
Here 4 values, so average = (61.58€ +82.58€ +114.96€ +63.78€)/4 = 322.90/4 = 80.72.

I can understand that you would like to have 322.90/3 because you selected "Previous 3 months".
This seems (To be confirmed) to be possible for the average but I don't know how to do for the tendency curve.

Could you confirm that I well understood your request ?
Did you see how I can do for tendency curve ?

Regards,
Stéphane
Comment 2 Fabiano Caruana 2024-05-02 13:45:34 UTC
Hi Stephane,

I think ist not a great problem, ... I can calculate.
it would be nice to see the correct "3 months value"

Greetings
Udo
Comment 3 Stephane MANKOWSKI 2024-05-02 14:06:27 UTC
(In reply to Fabiano Caruana from comment #2)
> Hi Stephane,
> 
> I think ist not a great problem, ... I can calculate.
> it would be nice to see the correct "3 months value"
> 
> Greetings
> Udo

I don't understand. You already have the correct "3 months value".
If you want full months, you must use "Previous 3 months" instead of "Last 3 months".
Comment 4 Fabiano Caruana 2024-05-03 15:39:40 UTC
Hi Stephane,

I wrote a script to transfer it to LibreOffice Calc and calculate “my” average values.

Greetings
Udo

see attachment from today
Comment 5 Fabiano Caruana 2024-05-03 15:40:39 UTC
Created attachment 169149 [details]
My average in Libreoffice calc
Comment 6 Stephane MANKOWSKI 2024-05-06 15:26:19 UTC
Ok. Understood. I will try to do a fix.
Comment 7 Stephane MANKOWSKI 2025-10-11 10:01:21 UTC
I'm trying to do the fix and I have many difficulties to find the good algorithm.

Indeed,
if dates = "Last 3 months" and columns="Month" then the average=sum/3 (even if 4 columns are displayed).

Easy ! But what to do in those cases:
- dates = "Last 6 weeks" and columns="Month"
- dates = "Last 3 month" and columns="Year"
- dates = "Personalized period" and columns="Month"

My proposal could be this one:
- If columns period is the same for dates (example: month in both), then the average is computed based on the real number of month instead of the number of cell. "Average (on month)" is displayed in the header.
- Else the average is compute as today.

Problem:
If dates = "Last 1 year" and columns="Month" then Average will be compute as today !!!

Do you have an idea covering all cases correctly ?
Comment 8 Fabiano Caruana 2025-10-12 10:43:34 UTC
Hi Stepahne,

Basic problem:
Periods with zero values ​​are not considered at the beginning and end of the selection period, but in between (see attachment).
Therefore, all periods should be considered (possibly adjustable via parameters).

Regarding the problems you mentioned, my suggestion would be that the average should generally correspond to the column selection.

First, I would like to assume that the fiscal month (30 days) and the fiscal year (360 days) should be used here.

And I see it like this:
> - dates = "Last 6 weeks" and columns="Month"
The average would be 1 month and 12 days = 1.4 months

> - dates = "Last 3 months" and columns="Year"
The average would be 0 years and 3 months = 0.25 years

> - dates = "Personalized period" and columns="Month"
Let's assume: 01-01-2023 to 23-08-2024
The average would be 19 months and 23 days = 19.77 months

I think this should be possible for the most cases, including.

> Problem:
> If dates = "Last 1 year" and columns="Month" then Average will be computed as today !!!
I think, that's identical to "Last 12 months"
That's the normal 12-month average. This version ("Last 12 months") is also my preferred one.

How do you see the chances of implementing this?
Another suggestion: If the result is incorrect or not, perhaps display the average in gray ink or something similar.

If I think of anything else, I’ll let you know.

Regards
Udo
Comment 9 Fabiano Caruana 2025-10-12 10:46:38 UTC
Created attachment 185713 [details]
Periods with zero values

To my Comment

regards
Udo
Comment 10 Stephane MANKOWSKI 2025-10-12 19:21:44 UTC
Hello,

Thank you for your reply.
The idea has the merit of being simple and quite easy to implement.
So, if the column = "Month", I calculate the number of months in the period and divide the total by that value.

Let’s imagine I pay a rent of 800€ at the beginning of the month.
If I select "Month" as the column and a period from 01/10/2025 to 15/10/2025, the average would be 1600€!
That would look strange, wouldn’t it ?
The idea of greying out the “partial” columns is a good one, but it wouldn’t be visible on the graph.

Any other ideas?
Comment 11 Fabiano Caruana 2025-10-13 10:48:45 UTC
Hi Stephane,

> Let's imagine I pay a rent of €800 at the beginning of the month.
> If I select "Month" as the column and a period from 01/10/2025 to 15/10/2025, the average would be €1600!
> That would look strange, wouldn't it?
That would not only be strange, but also completely pointless.
With only one column and only one data set, you can't expect a meaningful average.
That would be a case for "graying out."
Of course, a meaningful average requires multiple columns and data sets.
How many? Are two columns and two data sets sufficient?
I don't think so.
That's a matter of decision.

I have an example: September 30, 2025 = 5.95, October 1, 2025 = 3.60. Column by month.
That would currently be an average of 9.95/2 = 4.78 per month.
According to my calculations, 9.95*(1/30*2) = 0.66 per month.
Neither makes sense, but which is the better solution?
I'd say... none.

But that's my suggestion for solving it this way.
That's up to you, of course. You'll have to listen to the criticism.

I'll try to think about it.

Regards,
Udo
Comment 12 Fabiano Caruana 2025-11-20 17:31:47 UTC
Hi Stephane,

Consider this matter closed.
I'll take Skrooge as it is.

Thanks for your effort.

Regards,
Udo