Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Group & Record selection criteria Post Reply Post New Topic
Author Message
achandana01
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Online Status: Offline
Posts: 59
Quote achandana01 Replybullet Topic: Group & Record selection criteria
    Posted: 19 Mar 2012 at 12:35pm
Hi Folks,
 
I have the following sceneria
 
A customer bought various items from a store on different days and there is a cashiers who sold it.So I need this to be group by user,line# gives the order which he bought particlar items.I just put line# 2,4 for laptops but in reality it might be any number.Lets go the details
 
Customer # Purchase date Line Item Cashier
C100 12/1/2011 1 Bag John
C100 12/2/2011 2 Laptop John
C100 12/29/2011 3 Keyboard Michelle
C100 12/30/2011 4 Laptop Peter
C150 12/30/2011 1 Mouse Michelle
C150 12/30/2011 2 Laptop Michelle
 
I want the list of all the columns where the item is "Laptop".In this scenerio customer "C100" bought laptop twice but it doesnt mean he bought laptop twice may be some kind of exchange or minor repairs so I am interested only when he made his first purchase
 
Ex 1:
If I ran a report for the dates 12/29 thru 12/30 I should only see the following result
 
C150 12/30/2011 2 Laptop Michelle
 
In my report I did it like this way I grouped it by cashier,customer#in record selection : Item = "laptop" & Purchase Date in 12/29 to 12/30
Group Selection : Line = minimum(line,customer#) but I am getting the following data
 
C100 12/30/2011 4 Laptop Peter
C150 12/30/2011 2 Laptop Michelle
 
Ex2:
 
If I ran this same report for date 12/1 to 12/30 I shld get something like this
 
C100 12/2/2011 2 Laptop John
C150 12/30/2011 2 Laptop Michelle
 
Can someone able to help me out.I hope this make sense


Edited by achandana01 - 20 Mar 2012 at 7:17am
chand
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 20 Mar 2012 at 12:10am

Rather than try and show the correct individual records, I'd create a group that replicates the record you want to see and only display that. Surpress your details section.

Group by CUSTOMER and ITEM. Put any fields you want to see about the record in the ITEM group header or footer along with the following formula (We'll call it minpdate);
 
Minimum({table.purchasedate},{table.item}
 
Now apply only GROUP selection filters, not record selection filters, ie item = "laptop" and minpdate in 12/29 to 12/30
 
Regards,
Ryan.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 20 Mar 2012 at 5:07am
I agree with rkrowland...I would create a group, sort by date, and display the result in the group header.  Since the header is always the first record, and only the first record, it would be what you want.
 
Not that I am against formulas for grouping, since I use them all the time for exactly that purpose...it just seems like a bit more work than is needed.
 
and now you have at least 2 ways to do the same things, and new tools for future reports.
 
supressing the detail section is still valid, as you want the group header to display...not the details
 
HTH
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 21 Mar 2012 at 12:53am
Originally posted by lockwelle

I agree with rkrowland...I would create a group, sort by date, and display the result in the group header.  Since the header is always the first record, and only the first record, it would be what you want.
 
The thing is he doesn't always want to display the top record, he needs to filter entire groups out based on the minimum of the purchase date - otherwise I would have suggest the same method as you. :)
 
ie with your method filtering on table.purchasedate alone will return;
 
C100 12/30/2011 4 Laptop Peter
C150 12/30/2011 2 Laptop Michelle
 
where as he just wants;
 
C150 12/30/2011 2 Laptop Michelle
 
We filter out the Peter entry using the minpdate formula in my first post.
 
Regards,
Ryan.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 21 Mar 2012 at 5:19am
Couldn't just add another grouping based on the purchase date and pick the top one of that group?  That is how I would sort the data.
so he would have
gh1 customer          suppress
gh2 item                 suppress
gh3 purchase date   show  (suppress if not laptop)
 
 
Otherwise, I am fine will both the logic and the reasoning
 
ps After a bit of looking at CR and thinking about how I write reports, your methodology makes alot of sense.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.047 seconds.