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

Random records

Status
Not open for further replies.

KatieO

Instructor
Jul 19, 2001
4
US
I have create a record selection formula that returns 2500 records. I am creating a list that I'm going to sell - the buyer only wants 2000 records. How do I get a random selection from the 2500?
 
Here is a possiblility that I got to work.

Create a formula that will create a random number
"numbervar random:=rnd()"

Insert this field into your report and then sort on the field.

Finally conditionally suppress the detail by using
recordnumber>2000


 
Hi,

Another simple way is to sort on the last character of a particular field, eg. bank account number.

Anything that will be pseudo random will do!

Hth,
Geoff
 
here is a suggestion:

Create 3 array of 1000 elements (max allowed/array)

and fill the elements with numbers from 1 to 2500

then using a sort technique I used for shuffling decks of cards...shuffle the array elements

shuffle basics for 5 cards:

generate a random number between 1 and 4
swap the 5th card with that random number card

generate a random number between 1 and 3
swap the 4th card with that random number card

generate a random number between 1 and 2
swap the 3rd card with that random number card

One pass through the deck moves the card at least 2x

the trick is doing it for 2 arrays....but that can be done

now just take the first 2 arrays (2000 record numbers that you want) and sort low to high

now you have a basis for selecting and rejecting records...pretty random too.

Jim


 
I'd use the RND formula that mbarron suggests, but use a GROUP SELECTION FORMULA of
Recordnumber <= 2000

Rnd is only available in CR8, but I've a UFL that provides it for CR7 or earlier.

Editor of Crystal Clear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top