Solved

WHERE clause within IF/THEN/ELSE statement - CR XI

Posted on 2010-08-23
10
264 Views
Last Modified: 2012-05-10
Currently I have a parameter {?Class1}

I have one column of data the pulls based
"If {Command.Class}={?Class1}
Then {Command.Amount}
Else 0"

What I need, is a second column that pulls
" If {?Class1} = "Fall2010"
Then {Command.Amount} WHERE {Command.Class}="Spring2009"
Else 0"

Of course, this errors with everything from WHERE to the end as "...does not appear to be part of the formula."


SIDE NOTE: Command.Class is going to be Spring2011, Spring2010, Spring2009, spring2008, Spring2007, Fall2010,Fall2010, Fall2009, Fall2008, Fall2007
What I need is Crystal to select Command.Amounts based on previous class, but Fall2009 come after Spring2010 not Spring2009 so any other suggestions on how to do this would also be appreciated.

TIA
0
Comment
Question by:stlinae
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 33506639
Where are you doing this?

mlmcc
0
 
LVL 11

Author Comment

by:stlinae
ID: 33507470
I was creating a formula for it to run in the detail section.

(BTW, the data is coming from an QuickBooks SP_Report.)
0
 
LVL 4

Expert Comment

by:msd1305
ID: 33508130
do you mean this?

If {?Class1} = "Fall2010"  and {Command.Class}="Spring2009"
Then {Command.Amount}
Else 0


actually the question is still not very clear.. are you using this is in Record selection formula or is this a formula field?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 11

Expert Comment

by:tickett
ID: 33508289
msd1305's solution looks like what you want
0
 
LVL 2

Expert Comment

by:coronoahcoro
ID: 33509971
I don't think what msd1305 suggested is what stlinae want because it will be strange in this case if one record  has two class. I think what stlinae wants is when someone choose a class then CR puts the amount of that class in the first column and the rest of the columns put an amount from the previous term/season/class.

So let's say I choose Spring2010, then I want the amount from class Spring2010 to show up on the first column, the 2nd column will have the amount from Fall2010, 3rd column Spring 2009, and so on.

Please correct me if I'm wrong
0
 
LVL 2

Expert Comment

by:coronoahcoro
ID: 33510265
I was thinking to create a Formula  Fields with Select expression (call it ClassNum) that will look on the Class and set a number for them, like Spring2011 = 1, Fall2010 = 2. Spring2010 = 3, ...

With that I was thinking when a user choose a class, CR will put that amount class on the first column, look on the ClassNum field and create a second and the rest of the column based on previous ClassNum + 1 but of course I forgot that I don't know if CR can create a field programmatically.  
0
 
LVL 11

Author Comment

by:stlinae
ID: 33513059
coronoahcoro, you're onto the right idea. That's exactly what I want to happen. Of course I'm not sure I have any idea how to do it....

msd1305, I tried your suggestion, it brings back nothing but 0's, but thank you for the suggestion. And I'm using this in a formula field.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 33536749
I think you will have to use a subreport or a SQL expression.

Some information on SQL Expressions
http://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_23858441.html?cid=748#a27624600

mlmcc
0
 
LVL 11

Author Closing Comment

by:stlinae
ID: 33561886
While the excepted solution gives information on the steps needed to do this, I'm still completely lost on the HOW.
0
 
LVL 34

Expert Comment

by:James0628
ID: 33574014
FWIW ...

 I've been following this, but didn't jump in sooner because you'd gotten some suggestions and, frankly, I was being lazy and waiting to see how they panned out.  :-)

 If I follow what you're trying to do, I think you can do this with a cross-tab.  I do have a couple of questions though.

 You're trying to get a total of {Command.Amount} for each term, right?  For example, if someone asked for Fall2010, you'd have total columns like:

 Fall2010   Spring2010   Fall2009   Spring2009   Fall2008   Spring2008   <and so on>

 Assuming that I'm correct about that, are those grand totals for the entire report, or for some group on the report?

 If someone asks for Fall2009, for example, what happens to the records for terms after that (Spring2010, etc.)?  Do you have a record selection formula that will filter out those records or do they get included somewhere in your counts?

 James
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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