0
votes

I have a report format like

Main Report

Installment # 1

SubReport
---------------
     Group 1 (Suppressed)
        Group 2 Detail 1: 
          ID    Amount (Formula field)
          --   ------- 
           1     100


         Group 2 (Footer)
          ------------
          Total  200
          ------------

         Group 2 Detail 2: 
          ID    Amount (Formula field)
          --   ------- 
           1     300


         Group 2 (Footer)
          ------------
          Total  600
          ------------

Problem I am having is that I am having wrong totals for the formula field in my Group 2 footer (I cannot understand why they are doubled)

I am creating the total field in 2 steps. First I create the variable inside the detail section of Group 2

My formula field for the Amount

WhilePrintingRecords;

EvaluateAfter({@Share_Hundred_Percent});
EvaluateAfter({@Less_Commission});
EvaluateAfter({@Payment_NICL});
EvaluateAfter({@Payment_PRCL});

shared numberVar sumNetPayable;
numberVar result:=0;

if({Command.GENCLIENTCODE}=990) then
    result:= {@Share_Hundred_Percent}-{@Less_Commission} + {@Payment_PRCL}
else
    result:= {@Share_Hundred_Percent} - {@Less_Commission} ;

sumNetPayable := sumNetPayable + result;
result

Then I reset the total field in group 2 footer (but it prints double the amount)

My formula field to display the total

WhilePrintingRecords;
EvaluateAfter({@Net_Payable});

shared numberVar sumNetPayable;
numberVar result:= sumNetPayable;
sumNetPayable :=0;

result

Update

@SilentD. Here is what I found. I deleted both the formulas from the report design view (detail formula+summary). I only placed the Sum Fomula in footer and it works. But when I put the details formula in report the totals are doubled

1
If the results are doubled then the formula must be executing twice per record. Are there any other formulas that are referencing sumNetPayable? Or do you have your amount formula placed twice in the report?user496736
@SilentD nice comment, updated my post with new findings.Zo Has
Sum ({"Amount (Formula field)"},{"based on which field in group"})..This works for me in general, you can customize it. Do check formula if it not having weird logic hidden. :)JulyOrdinary
Are you resetting the formula in group 2 header?Siva
I guess you may have 2 details so when you are using that formula that is calculating 2 times so that is the reason I have asked you to try by removing that..Siva

1 Answers

1
votes

In the end what fixed my problem was to remove the EvaluateAfter({@Net_Payable}); from my formula field used to display the total in group footer. For some reason it was doubling the calculation.

WhilePrintingRecords;

shared numberVar sumNetPayable;
numberVar result:= sumNetPayable;
sumNetPayable :=0;

result