Crystal Reports 2008

Posted on 2011-10-03
Last Modified: 2012-05-12
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
then by:
a.Fixed Rate
c.Adjustable Rate (<= 1yr)
d.Adjustable Rate(> 1yr)
Then by:
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
                                 >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}<=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.
Question by:moni81011
    LVL 100

    Accepted Solution

    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
            Else If {@DaystoRateChange}<=12 then
               "Adjustable Rate 1 yr or less",
               "Adjustable Rate > 1 yr
    Else If isnull({stored procedure;1.FirstRateChangeDate}) then
         "Closed-end Fixed Rate",

    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
                   report ADJUATABLE 1 YR OR MORE
            report BALLON/HYBRID
    Else ( type 2 2nd mortgage)
         If it doesn't have a balloon date then
                report CLOSED-END FIXED RATE
                report ""

    does that sound correct.  



    Author Closing Comment

    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!

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now