Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formulas in Parameters? Post Reply Post New Topic
Author Message
Lewe22
Newbie
Newbie


Joined: 04 Jan 2008
Online Status: Offline
Posts: 7
Quote Lewe22 Replybullet Topic: Formulas in Parameters?
     Posted: 04 Jan 2008 at 7:05am
I am new to crystal and am having trouble working out how to incorporate a formula in my parameter.
 
I want to prompt the user for a year (eg: 06) and then display 06 data as well as any previous years data.
 
I have succesfully created a parameter which will return a single year's data but am struggling when trying to incorporate the previous years.
 
Any help would be greatly appreciated!!
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 04 Jan 2008 at 9:12am
There are a few ways to accomplish this, which all basically do the same thing.

{MyReport.MyDate} < {?EnterDate}

{MyReport.MyDate} IN UpTo {?EnterDate}

{MyReport.MyDate} BETWEEN '01/01/1970' AND {?EnterDate}

The first one is pretty simple, and I think is the one that Crystal will create by default with the Select Expert.  The second uses the range operator UpTo, which you can check out in the help file.  The third is particularly useful if you want to exclude bad dates in some way.


IP IP Logged
Lewe22
Newbie
Newbie


Joined: 04 Jan 2008
Online Status: Offline
Posts: 7
Quote Lewe22 Replybullet Posted: 07 Jan 2008 at 1:23am

Where exactly do i enter these formulas?

I have tried entering it as a group selection formula but am receiving the same set of results.
 
My formula:
 
{ViewExamHistESOL.ESOLExamHistSess} <= {?Session}
 
Where Session is the declared parameter field.


Edited by Lewe22 - 07 Jan 2008 at 1:23am
IP IP Logged
Savan
Senior Member
Senior Member
Avatar

Joined: 14 Dec 2007
Location: India
Online Status: Offline
Posts: 162
Quote Savan Replybullet Posted: 07 Jan 2008 at 1:45am

you can filter the records by using the select expert option in report menu. select the field based on which u want  to filter the data.  after that select the appropiated condition (i.e greater than,  less than etc) and the select your paramter.  based on your condition your records are filtered. Thumbs%20Up

Thanks
Savan
IP IP Logged
Lewe22
Newbie
Newbie


Joined: 04 Jan 2008
Online Status: Offline
Posts: 7
Quote Lewe22 Replybullet Posted: 07 Jan 2008 at 3:38am
That's great thanks. Formula works fine now, however my result set is still not exactly as i had hoped, hope someone can help!
 
I work for a college and am trying to retrieve a history of enrolments for students who had an enrollment in a particular year (session). 
 
For example
 
The user is prompted for a year.....
User selects 06.....
Report returns list of students who enrolled on a course that year, as well as any previous enrolment history.
 
At present my report is listing all enrolments prior to and including 06. 
I need to remove any records where there was no enrolment against that student for 06. ie, a student might be appearing with enrolments in 04 and 05 only.
This is getting confusing, hope that makes sense!
 
My current formula is
 
ToNumber({ViewExamHistESOL.ESOLExamHistSess}) <= ToNumber({?Session})
 
I usually deal in SQL but Crystal is the only option for this database.


Edited by Lewe22 - 07 Jan 2008 at 3:44am
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 07 Jan 2008 at 5:01am
As a note, you can use SQL in Crystal (assuming the database supports it).  When selecting your data source, instead of selecting a table or view, select Add Command.  This allows you to enter your own SQL.

Which, given your requirements, may be desired.

For straightforward selection criteria, you may be out of luck (or, at least, out of your depth).  However, there is a relatively simple workaround.  Using the criteria you have now, group your report on student.  Put suppression criteria on the group and details section that look like:

Maximum ({ViewExamHistESOL.ESOLExamHistSess} ,{ViewExamHistESOL.StudentID}) <> {?Session}

That will hide any student who is not enrolled this year.  Note that the data is still pulled for all students, so there is still the performance hit (and possible storage hit, if you are saving the data with the report).  But, it does provide the results you are looking for.


IP IP Logged
Lewe22
Newbie
Newbie


Joined: 04 Jan 2008
Online Status: Offline
Posts: 7
Quote Lewe22 Replybullet Posted: 08 Jan 2008 at 8:00am
Thanks!
 
I have now restricted my data using SQL as you suggested. (Don't want to go down the other route for performance reasons.)
 
I have inserted an SQL statement as a command which includes the parameter SESS.
 
I'm baffled about this parameter though as it doesn't prompt the user for SESS when the report is run. Am i doing something wrong?
 
It does prompt me for it when i close the 'Modify Command' dialog box though, i'm confused....HELP!
 
 
 
 
 


Edited by Lewe22 - 09 Jan 2008 at 3:23am
IP IP Logged
Lewe22
Newbie
Newbie


Joined: 04 Jan 2008
Online Status: Offline
Posts: 7
Quote Lewe22 Replybullet Posted: 09 Jan 2008 at 3:23am
Can anyone out there help me? I'm well and truely stuck!!

Edited by Lewe22 - 09 Jan 2008 at 3:24am
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 09 Jan 2008 at 5:03am
You'll need to create a parameter field for the report, and use it in your SQL instead of a traditional parameter.  If you look up parameter fields in the help file (or in Brian's book, which is much clearer), it should point you in the right direction.


IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum