Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find 20 random records

Status
Not open for further replies.

satinsilhouette

Instructor
Feb 21, 2006
625
I need to find 20 random records out of thousands. In excel this is easy. How do I do it in Crystal 11?

Thanks!

Thanks so much!
satinsilhouette
 
Create a formula:

rnd()

Add this to your detail section and to report->sort records. Then use a detail suppression formula like this:

recordnumber > 20

-LB
 
Thank you, I thought that was round.

Thanks so much!
satinsilhouette
 
Okay - that gives me 20 records, but not 20 unique records. How do I get 20 unique records?

Thanks so much!
satinsilhouette
 
Add this to your detail section:

//@Random_Value
Whileprintingrecords
Numbervar random
If previous {result of RND()}<> { result of RND()} then random_:=random+1 else random:=random

Then use a detail suppression formula like this:

Previous({result of RND()})={result of RND()} or {@Random_Value}>20
 
That IS 20 unique records. It is not random however, it just shows you the first 20 records. Please post samples of your data and desired results.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
If you accept that RND() gives a random number the approach I outlined gives 20 unique random numbers.
 
Thanks folks! Appreciate the help!

Thanks so much!
satinsilhouette
 
Dharma,

My bad,I misread your post. That would indeed give you 20 random records.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top