Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: selection criteria help Post Reply Post New Topic
Author Message
anu009
Newbie
Newbie


Joined: 18 Aug 2010
Online Status: Offline
Posts: 28
Quote anu009 Replybullet Topic: selection criteria help
     Posted: 03 Mar 2011 at 1:53pm
I have two table with one to many relationship.One Student record can have multiple rows in the secondsubject  tbl.
 
I have to work on a condition where if record A from table 1 has only one record with string "Maths"in table 2  then dispaly Y but if has "Maths" plus some other subjects too then display N.
 
My report is giving Y in a case where there are multiple records with "maths" as one of them. which is wrong as in that case i would like to see only N.
 
how to check for this condition in the report.I am nt sure how to do a if loop to check all the records for Student A from tbl 2.
Example
A -Maths
A -Science then N
 
if B -Maths then Y.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 04 Mar 2011 at 3:46am
If I understand you correctly, you want a "Y" if "Maths" is the only subject and "N" if there are any other subjects, correct?
 
You're going to need to use a variable in a formula to do this.  Assuming you're grouping on something like StudentID, the formula is going to look something like this:
StringVar isMathsOnly;
if (PreviousIsNull({student.StudentID}) or {student.StudentID} <> Previous({student.ID})) then
  if {secondsubject.Subject} = "Maths" then
    isMathsOnly := "Y"
  else
    isMathsOnly := "N";
else
  isMathsOnly :="N";
isMathsOnly
 
You'll probably have to tweak this to meet your needs and you may not need the semi-colon (;) highlighted in red but it should give you a starting point.
 
-Dell
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