Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Newbie in a Catch-22... Post Reply Post New Topic
Author Message
kgbergman
Newbie
Newbie
Avatar

Joined: 21 Sep 2010
Location: United States
Online Status: Offline
Posts: 3
Quote kgbergman Replybullet Topic: Newbie in a Catch-22...
     Posted: 21 Sep 2010 at 8:16am
Mornin', all...
 
I'm pretty new to the Crystal Method of data reporting and am stuck on a new task I have.
 
I have a report that I send two parameters to: Part Class and Ever/Never.
 
Based on those two parameters, I want to report on that Class and whether they have Ever or Never been sold.  Ever or Never been sold is based on a field in the data I'm gathering: TranType.
 
A sample data set is:
 
Part  TranType   LastDate
A       XADJ         6/30/2010
A       REL           5/25/2009
B       XADJ         6/30/2010
C       XADJ         6/30/2009
C       REL           4/20/2009
 
If I request Ever, I want
A       REL           5/25/2009
C       REL           4/20/2009
 
If I request Never, I want
B       XADJ         6/30/2010
 
All 3 parts have the XADJ type, but only one of them has ONLY the XADJ type.  How do I exclude the ones that have multiple trantypes and just get the ones that only have one trantype?
 
I'm using CR10.
I also have a group select of:
lastdate=maximum(lastdate, trantype) so that I only get the last date for that trantype.
 
Any help would be greatly appreciated.
 
Karl
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Sep 2010 at 8:49am
if you cannot do data manipulation outside of crystal (e.g. a sql view)...
also I am assuming you want your part type in the ever / never to be dynamic and not just looking at "XADJ"
 
group on part
create a formula to flag your rows with your part  called 'flag'
if TranType={?Tran Param} then 1 else 0
Do a SUM of this at the Part group
SUm(@flag,part)
 
in the select expert Record selection
{?Ever/never} param='Never'
or
({?Ever/never} param='Ever' and {?Tran Param} ={TranType})
 
now toggle to the group select and add you other criteria
{?Ever/never} param='Ever'
or
({?Ever/never} param='Never' and {?Tran Param} ={TranType}
SUm(@flag,part)=Count(part,part))


Edited by DBlank - 21 Sep 2010 at 8:50am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Sep 2010 at 9:15am
rereading this i think your example was using the param Trantype="REL"
If that is the case, this changes the way this would work.
eveything is the same other than your select statements.
There is no select expert for Record selection.
Your group selection would be:
({?Ever/never_param}='Ever' and Sum(@flag,part)>0))
or
({?Ever/never_param}='Never' and Sum(@flag,part)=0))


Edited by DBlank - 21 Sep 2010 at 9:16am
IP IP Logged
kgbergman
Newbie
Newbie
Avatar

Joined: 21 Sep 2010
Location: United States
Online Status: Offline
Posts: 3
Quote kgbergman Replybullet Posted: 21 Sep 2010 at 9:28am
Thanks!  That was quick!
 
I'm not sending a {?Tran Param} so I don't understand where that comes in.  And if I'm not sending that param, what other way is there to sum for a count?
 
'Ever' should show me any parts that have more than one trantype.

'Never' should show me parts that have only one trantype.
(If there is only one trantype then it's automatically XADJ)

'Class' just narrows down the number of parts to start with.
 
I'll try that summing thing, but I think I'm still misunderstanding something.
 
Thanks again!
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Sep 2010 at 9:37am

OK I assumed incorrectly that the 'Class' you referred to was in the sample data as Tran_Type.

So 'Ever' means that the the Part has more than one Tran Type
and Never means only only one Tran_type.
Not sure in your sample why you keep exluding the XADJ rows but here is the updated version of the group select statement. YOu will have to explain further why the XADJ rows are omitted.
 
({?Ever/never_param}='Ever' and DistinctCount(TranType,Part)>1)
or
({?Ever/never_param}='Never' and DistinctCount(TranType,Part)=1)
 


Edited by DBlank - 21 Sep 2010 at 9:37am
IP IP Logged
kgbergman
Newbie
Newbie
Avatar

Joined: 21 Sep 2010
Location: United States
Online Status: Offline
Posts: 3
Quote kgbergman Replybullet Posted: 21 Sep 2010 at 10:50am

OK - XADJ simply means that a part has been inventoried.  This is literally true for every part.  Some parts have only ever been inventoried and never sold.  I'm not trying to exclude any specific trantype, but if it only has one it will have to be XADJ, thus never sold.

So, now ordered by part, with the last code in the group select, gives me exactly the results I was looking for - I never even looked at distinctcount for a subgroup, group.

Thanks - I'm all set!

Karl
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