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?
 
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


 
0
 
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!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.