Implementing "sum of" or "average of" fields in a Base reoprt

Still working on converting a FileMakerPro database and reports to LibreOffice Base…

The basic issue is that FileMakerPro has the concept of “sum of” fields for reports. (Maybe also “average of,” etc.?) If your report has detail rows with values, but then the report is broken up by category,

Here’s the setup.

  • DayTab has one row per day with a date and a value.
  • MonthTab has several values for the month including first and last day of the “month.” The definition of “month” is fluid since it depends when the given values are recorded. That varies around a bit because they don’t happen on weekends or holidays. And that’s usually somewhere around the 20th of the month.
  • MonthReportQuery pulls the values from MonthTab and the sum of values in the appropriate entries in DayTab, plus several calculations on those fields to compute perfornance for the month.

So far so good. It took a bit of fancy footwork to get the MonthTab sums right, but it works.

But here’s the rub. I also need a running total for the year. (Where “year” isn’t a calendar year, it starts in April, another minor complication.) In FileMakerPro I just define some “sum of” fields that automatically sum the computed fields and the sum resets at the start of each year.

How to do the same in Base?

I figure I could make a RunningMonthReportQuery that pulls values from MonthReportQuery plus sums all of the previous MonthReportQuery entries for the relevant fields.

Or maybe adjust MonthReportQuery so that it, itself, recomputes all of the running totals after figuring out where the start of the “year” is. But both of sound like there’d be an awful lot of work recreating sums from raw data instead of using sums of sums.

Is there some clever Base way to do this kind of thing that I’m missing?

[DB = Firebird]
“FiscalYear” you get from the formula in your other thread, and will be a column in your “View1”.
Then on another View running total will be like

[...], SUM("TheField") OVER (PARTITION BY [...] ORDER BY [...]) AS "YearRT"
FROM "View1"

Also in the Report it can be defined a “User Function” computing a RT.
So yes: Report Builder also have sum of fields functions.
But you should post a sample of your data for a specific tentative answer/solution.

Base is not a DB. It connects to DBs.

Best way to create reports: All calculations will be made in the database, not in report. Create correlated subqueries for all needed data. Take the query and create a view of this query.

If you try it through the report it will run very slow and often won’t show the expected result (nothing instead of a result…)

Might be you are looking for a report like this. All calculations are made in a view