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

Randomizing Numbers in Crystal

Status
Not open for further replies.
Dec 13, 2004
63
0
0
US
Hi,

I am using CR X with an Oracle DB.

I have 100 employee records. I would like to give each employee a 9 digit random number. Please help!

 
Could I clarify why you want to generate a random 9 digit number *within* crystal?

Would you want this number to be randomised every time you generate the report?

Also, would you want the randomised number for each employee to stay specific to the employee?

'J
 
Yes, I would like to randomize the numbers in Crystal. I do want the number to be specific to each employee. Also, the number can change each time I refresh the report.

 
Normally the Rnd() function is to be used in this case.

Rnd() generates a random number between 0 and 1. Use this as a base to then generate a 9 digit number by multiplying it by whichever required amount.

In this case a formula as follows:

//{@random}
Rnd() * 1000000000

I noticed though that this sometimes only generated an 8 digit number. So maybe couple this with another formula to check length and fix to 9 digits.

//{@check}
if len(totext({@random})) = 8 then {@random} * 10 else {@random}

Sort by this as a group and suppress where ({@random}like previous({@random}) to remove dupes.

'J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top