Question : How to sum a formula involving a nested if statement in Crystal 2008

Good Morining Experts!

I have  a commission report which calculates straight commission as well as "Overage" paid to Sales People.  Over the years the deal that sales people recieve for the percentage of the overage that goes to them as apposed to the company has changed serveral times, resulting in 5 different calculations of the percentage of overage most of which adjust based upon the total volume closed.  In order to handle this I've created the following formula:

if {CB_Originator_View.ComType} = 1
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) < 1500000 then {ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.5
else if {CB_Originator_View.ComType} = 1
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 1500000 to 2499999 then {ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.6
else if {CB_Originator_View.ComType} = 1
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) >= 2500000 then {ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.65
else if {CB_Originator_View.ComType} = 2 then {ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.6
else if {CB_Originator_View.ComType} = 3 then {ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.65
else if {CB_Originator_View.ComType} = 4 then {ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.75
else if {CB_Originator_View.ComType} = 5
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) <= 2500000 then {ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.6
else if {CB_Originator_View.ComType} = 5
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) > 2500000 then {ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.65

This is working fine but I need to total the amount of overage at the group level and I'm lost on how to do that, Normaly I would use a running total, or insert a summery but I can't choose that formula in the summery wizard and I'm not sure how to do the running total with so many variables.

Answer : How to sum a formula involving a nested if statement in Crystal 2008

If you change the structure of your current formula slightly it will be much easier to do the accumulation..

numbervar comm;
numbervar commtotal;

if {CB_Originator_View.ComType} = 1
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) < 1500000 then
comm:={ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.5
else..........etc
.....
else if {CB_Originator_View.ComType} = 5
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) > 2500000 then
comm:={ISB_Commissions_view.totalloanamount} * {LO_Commisions.OverageBasis} * 0.65;
commtotal:=commtotal+comm;
comm

You'll need another formula field at the beginning of the group to set commtotal to 0 and another formula field in the group footer to display the value of commtotal
Random Solutions  
 
programming4us programming4us