Reputation: 45
I am working on this report pulls all of our Projected Purchases grouped by Month displaying a sum (called "Monthly_Total"
for the month as well as displays the Budget (called "Monthly_Budget"
for the month. I also have a subreport that I use a shared currencyvar "Starting_Balance"
. This shared variable updates whenever the report is run.
I need to find a way to do the following calculation:
for the first month (in this case the report starts with March) it should be
"Starting_Balance" + "Monthly_Total") - "Monthly_Budget" = "New_Balance"
each subsequent Month would use the formula
("New_Balance" + "Monthly_Total") - "Monthly_Budget"
I can get it to work for the first group footer, but with then each month after that is referencing back to the "Starting_Balance"
rather than the "New_Balance"
any ideas?
Upvotes: 1
Views: 9820
Reputation: 732
Try using a flag variable that says whether or not the first month has been reported yet. I originally though of using New_Balance as 0, but that could potentially happen naturally.
So, something like
Initializer in the report header:
WhilePrintingRecords;
Global BooleanVar First_Month_Done := false; // have we printed the first month?
""; // print nothing on screen
Monthly formula
WhilePrintingRecords; // Optional when using shared variables
Global BooleanVar First_Month_Done;
Global CurrencyVar New_Balance; //or whatever it is
Shared CurrencyVar Starting_Balance;
// Assuming "Monthly_Total" and "Monthly_Budget" are formulas, not variables
If First_Month_Done
Then New_Balance := New_Balance + {@Monthly_Total} - {@Monthly_Budget}
Else New_Balance := Starting_Balance + {@Monthly_Total} - {@Monthly_Budget};
First_Month_Done := true;
New_Balance
Upvotes: 1