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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random selection of data

Status
Not open for further replies.

dzavad

Programmer
Apr 17, 2000
167
US
I am using cr10. I need a random selection of data prodused in the report output that have a status of open in the system. I want to specify (for example) “10” open claims to be returned in the report rendomly.
Is it posible to do?
 
Yes.

The key here is to return all of the records in the database and to conditionally suppress all of them except the randomly chosen ones to view.

First create a formula to randomly select 10 records:

Code:
WhilePrintingRecords;
Numbervar Array array1;
Redim array1 [10];

Local NumberVar i;
    For i := 1 to 10
    Step 1
    Do(array1 [i] := 1+Truncate RND()*Count({YourField}))) ;

Replace {YourField} with any recurring, non-null field in your database. Replace 10 with the number of random records you would like to see.

Then add the following to the section expert under the suppress formula to suppress those not in the random selection:

Code:
WhilePrintingRecords;
NumberVar Array Array1;
not (RecordNumber = Array1)


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