Question : nested if statemest in crystall 2008

I am attempting to automate a very manual commissions process.  As time has gone on different loan officers have been hired with different commsiion schedules that affect the number of Basis Points they recieve from each closed loan.  I have grouped these different schedules into 10 commission types and created a field in the database to track the commission type of each loan officer.  Within each of the different commision types there are also the type of loan and the total amount of business done durring the month as variables.  I know I could do this with else if statements as follows:

NumberVar BP;
numbervar BPTotal;

if {CB_Originator_View.ComType} = 1
and {ISB_Commissions_view.alias2} = "ISB"
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) < 500000 then BP:= 30
else if {CB_Originator_View.ComType} = 1
and {ISB_Commissions_view.alias2} = "ISB"
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 500000 to 999999 then  BP:= 35
else if {CB_Originator_View.ComType} = 1
and {ISB_Commissions_view.alias2} = "ISB"
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 1000000 to 1499999 then BP:=40
else if {CB_Originator_View.ComType} = 1
and {ISB_Commissions_view.alias2} = "ISB"
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 1500000 to 1999999 then BP:=45
else if {CB_Originator_View.ComType} = 1
and {ISB_Commissions_view.alias2} = "ISB"
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 2000000 to 2499999 then BP:=50
else if {CB_Originator_View.ComType} = 1
and {ISB_Commissions_view.alias2} = "ISB"
and Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) >= 2500000 then BP:=55;
BPTotal:=BPTotal+BP;
BP

And then of course I would repete for the type of loan (over which there are several).  What I'm wondering is can I do an actual nested if such as:

if {CB_Originator_View.ComType} = 1
              {ISB_Commissions_view.alias2} = "ISB"
                       Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) < 500000 then BP:= 30
                       Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 500000 to 999999 then  BP:= 35
                        Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 1000000 to 1499999 then BP:=40
                        Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 1500000 to 1999999 then BP:=45
                        Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 2000000 to 2499999 then BP:=50
                        Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) >= 2500000 then BP:=55

Answer : nested if statemest in crystall 2008

You should be able to nest it the way I described, but i think nesting a switch inside a switch might get a little hairy...

Maybe something like this?

BP:=
IF {CB_Originator_View.ComType} = 1
THEN
    (IF  {ISB_Commissions_view.alias2} = "ISB"
        THEN (switch Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) < 500000, 30,
                Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 500000 to 999999, 35,
                ....and on and so forth
              TRUE, 55)
     ELSE IF {ISB_Commissions_view.alias2} = "FNMA"
        THEN (switch Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) < 500000, 30,
                Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 500000 to 999999, 35,
                ....and on and so forth
              TRUE, 55)
      )

ELSE IF {CB_Originator_View.ComType} = 2
THEN
    (IF  {ISB_Commissions_view.alias2} = "ISB"
        THEN (switch Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) < 500000, 30,
                Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 500000 to 999999, 35,
                ....and on and so forth
              TRUE, 55)
     ELSE IF {ISB_Commissions_view.alias2} = "FNMA"
        THEN (switch Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) < 500000, 30,
                Sum ({ISB_Commissions_view.totalloanamount}, {@LO}) in 500000 to 999999, 35,
                ....and on and so forth
              TRUE, 55)
      )

ELSE 0
Random Solutions  
 
programming4us programming4us