Crystal Reports 2008

I am trying to create a report using Crystal Reports 2008 and a stored procedure in SQL 2008.
For my end result, I want the loans grouped by:
1.Lien Position
a.1st
b.2nd
then by:
2.@Adjustable
a.Fixed Rate
b.Balloon/Hybrid
c.Adjustable Rate (<= 1yr)
d.Adjustable Rate(> 1yr)
Then by:
3.@Type
a.> 15yrs
b.<= 15yrs
c.> 5yrs
d.<= 5yrs
Part of the report should look like this:
                                                    # of loans             Amount
First Mortgages
      Fixed Rate
                               >15yrs                  500            50,000,000
                               15 yrs or less      1,000        60,000,000
      Balloon/Hybrid
                                 >5yrs                  10               500,000
                                  5 yrs or less     50              1,000,000
      Adjustable Rate
                              1yr or less            20              2,000,000
                             >1 yr                       100            10,000,000
Other Real Estate (2nd liens)
      Closed End Fixed                      400            10,000,000
TOTAL                                                 2,080      133,500,000

Here is the code that I have for @Adjustable:
iif({stored procedure;1.LienPosition}="1",iif(isnull({stored procedure;1.BalloonPayDate}),iif({stored procedure;1.LoanPayType}="F","Fixed Rate",
iif({@DaystoRateChange}=0,"Other",
iif({@DaystoRateChange}<=12,"Adjustable Rate 1 yr or less","Adjustable Rate > 1 yr"))),"Balloon/Hybrid"),
iif(isnull({stored procedure;1.FirstRateChangeDate}),"Closed-end Fixed Rate",""))
@DaystoRateChange code:
iif(isnull({stored procedure;1.FirstRateChangeDate}),0,
iif({stored procedure;1.FirstRateChangeDate}<=CurrentDate,
{stored procedure;1.MthsBetweenChg},datediff("m",cdate({stored procedure;1.OpenedDate}),
{stored procedure;1.FirstRateChangeDate})))

@Type code:
  iif({@Adjustable}= "Fixed Rate",iif({@YrsToMaturity}>15,">15 Years","15 Years or less"),
iif({@Adjustable}="Balloon/Hybrid",iif({stored procedure;1.LienPosition}="1","> 5 Years",
iif({@YrsToMaturity}>5,"> 5 Years","5 Years or less")),""))

The results I am getting are only two loans that fall in the fixed rate category, which is incorrect.
 Majority of the loans should fall under 1st lien fixed rate.Then some fall under
Adjustable Rate > 1 yr and the rest fall under “Other” which is also not correct. I am inserting
groups for Lien position, Adjustable and Type and specify an order within the groups.  Any help
 would be greatly appreciated.  I am not too familiar with Crystal Reports would appreciate
your help.
moni81011Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
The way you are using IIF makes it very difficult to follow.

It would be easier if you wrote it with an IF THEN ELSE

I assme you have LienPosition as a 1 or 2.  As written all 2s are "" or Closed-end Fixed Rate which aren't among the listed choices.

I believe I converted this correctly

 
if {stored procedure;1.LienPosition}="1"  then
    if isnull({stored procedure;1.BalloonPayDate}) then
        if  {stored procedure;1.LoanPayType}="F"  then
           "Fixed Rate",
        Else IF {@DaystoRateChange}=0  then
           "Other",
        Else If {@DaystoRateChange}<=12 then
           "Adjustable Rate 1 yr or less",
        Else 
           "Adjustable Rate > 1 yr
    Else 
        Balloon/Hybrid"
Else If isnull({stored procedure;1.FirstRateChangeDate}) then
     "Closed-end Fixed Rate",
Else
      "";

Open in new window



In English
If it is a first (1) mortgage then
    If it doesn't have a balloon date then
          If it type F then
                report FIXED
          Else  if the days to the next change is 0
               report OTHER
          Else if the days to change <= 12 then
               report ADJUATABLE 1 YR OR LESS
          Else
               report ADJUATABLE 1 YR OR MORE
     Else
        report BALLON/HYBRID
Else ( type 2 2nd mortgage)
     If it doesn't have a balloon date then
            report CLOSED-END FIXED RATE
     Else
            report ""

does that sound correct.  

mlmcc


 

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
moni81011Author Commented:
This worked perfectly!!!
I did not write the initial code and you are right, it is a bit hard to understand.  I will try to use the IF THEN ELSE from now on.
Thank you soooooooooooooo much for your help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.