Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Record Selection formula Post Reply Post New Topic
Author Message
brad_lucas
Newbie
Newbie


Joined: 19 Jul 2011
Location: Australia
Online Status: Offline
Posts: 4
Quote brad_lucas Replybullet Topic: Record Selection formula
     Posted: 21 Jul 2011 at 7:28pm

Firstly, I’m sorry for such a long winded post, I am trying to be as precise as I can, so that I can give you enough info to assist me.


I work for a school and have been tasked with fixing up the school assessment reports. One of the reports I’m working on is a comparative summary of the grades for each subject in a given year level.


For example, English:

A    11
A+   8
B    3
B+   13 etc and so on.


Each subject area has what’s called an Assessment Code.  So year 10 English would be 10ENG, year 9 Maths would be 09MAT etc.


The report is simply passed the Assessment Code as a parameter and returns all the grades associated with it and then does a running tally for each. Simple.


My issue is that year 10 Maths has been separated into three Assessment Codes with only the final character different (10MAT, 10MAF & 10MAE). "They" want all three Assessment Codes to be tallied together as if they were one. 


I figure that because the Assessment Code is pretty standard (5 characters, first 2 being a number) I could simply replace the final character with a wildcard. So I’d end up with something like 10MA%.


So in the Record Selection formula I did this:

{ AssessmentCode} LIKE LEFT({?Pm- AssessmentCode},4) + '*'

I test the SQL that’s generated and I get

WHERE AssessmentCode LIKE ‘10MA%’


Perfect, except, when I run the report the tally doesn’t add up. The results I should get (according to the SQL) are:

A    11
A+   8
B    3
B+   13
C    9
C+   7
D    6
D+   12
E    3
E+   4


The results I’m actually getting (according to the report) are:

A     0
A+    0
B     0
B+    0
C     1
C+    0
D     1
D+    0
E     1
E+    1


I've been working and researching this all week and I’m utterly stumped if I can figure out what I’m doing wrong. I'd appreciate ANY guidance on the matter.


Kind regards,
Brad



Edited by brad_lucas - 21 Jul 2011 at 7:32pm
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 22 Jul 2011 at 2:39am
I don't believe you will need to add that "wild card" part. You should just be able to select on the first four and it will take all.
|< /\ '][' ( )
IP IP Logged
brad_lucas
Newbie
Newbie


Joined: 19 Jul 2011
Location: Australia
Online Status: Offline
Posts: 4
Quote brad_lucas Replybullet Posted: 22 Jul 2011 at 3:54am
So, are you saying I can use just this and it'll work?:

{ AssessmentCode} LIKE LEFT({?Pm- AssessmentCode},4)
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 22 Jul 2011 at 3:59am
I don't know the CR sql convention, but for SQL you need the wildcard.
 
if you do:
select * from table where field like 'xyz'
this is the same as
select * from table where field = 'xyz'
 
select * from table where field like 'xyz%' will give all records that start xyz.
 
A suggestion is (if you can) to use your database and run a trace or profile on what is being requested (you can do this in sql server under tools), this way you will be able to see what the report is requesting, which might help in the debugging.
 
HTH
IP IP Logged
brad_lucas
Newbie
Newbie


Joined: 19 Jul 2011
Location: Australia
Online Status: Offline
Posts: 4
Quote brad_lucas Replybullet Posted: 24 Jul 2011 at 1:09pm
Thanks for the tip on running a trace, however, it's confused me even more. The query that CR is passing to the database is correct:

SELECT
   AssessResultsResult
FROM
   vStudentReportsSemesterResults
WHERE
   AssessmentCode LIKE '10MA%'
ORDER BY ID DESC

I guess that means I've at least ruled out the SQL as the issue. Now to look at the running totals.

Thanks for your help.
Brad
IP IP Logged
brad_lucas
Newbie
Newbie


Joined: 19 Jul 2011
Location: Australia
Online Status: Offline
Posts: 4
Quote brad_lucas Replybullet Posted: 24 Jul 2011 at 8:17pm
This is really driving me nuts! The report has a running total for each grade (A+, A, B+ etc) and it's using the following formula (obviously replace the A+ with whichever tally you're up to):

if OnLastRecord
then {AssessResult} = "A+"
else
if next ({AssessAreaHeading}) = 'Adjusted Mark' and next({AssessResultsResult}) <> ''
then {AssessResultsResult} = "B-"
else
{AssessResultsResult} = "A+"


Here's a sample of the data. The bold is what I'd expect to be tallied. Can anyone make heads or tails out of this?

AssessResult    AssessmentCode  AssessAreaHeading    ID
===========================================================
C              10MAT            Progress Result      37015
                10MAT            Adjusted Mark        37015
C               10MAT            Progress Result      36998
                10MAT            Adjusted Mark        36998
C+              10MAT            Progress Result      36592
NA              10MAT           Adjusted Mark        36592
N/A             10MAE            Progress Result      36334
A+              10MAE            Adjusted Mark        36334
C               10MAT            Progress Result      36067

                10MAT            Adjusted Mark        36067
A               10MAT            Progress Result      35598

                10MAT            Adjusted Mark        35598
N/A             10MAE            Progress Result      35588
A+              10MAE            Adjusted Mark        35588
C+              10MAF            Progress Result      35573
                10MAF            Adjusted Mark        35573
C               10MAT            Progress Result      35499
               10MAT            Adjusted Mark        35499

Thanks for your advice.
Brad
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 26 Jul 2011 at 3:15am
simply mistake...
if you are using Crystal Notation, the assignment operator is :=, not =...that is the comparator....kinda like c with = and ==
 
HTH
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