Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Randomly Select Post Reply Post New Topic
Author Message
VickiM
Newbie
Newbie
Avatar

Joined: 02 May 2011
Location: United States
Online Status: Offline
Posts: 28
Quote VickiM Replybullet Topic: Randomly Select
     Posted: 09 Jan 2012 at 5:06am
Hi!  Is there a way in Access 2007 or in Crystal Reports 11 to write a query that will randomly select names from a list of employees meeting certain criteria?  I have written the query to pull in the people with the specific critera, but I don't need all of them.  I was told to randomly select 20 people on a monthly basis.  Is that possible?  Any help you can give me will be appreciated.  Thanks!
VickiM
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Jan 2012 at 8:09am
How I did this in crystal
Either use a source that limits the employees to your overall match or use the select expert in crystal to limit the data set to all employees in your match
create a formula to generate a "random number"
//RandomNumber
Int(rnd()*1000000)
Place this formula field on the detail row in crystal.
Sort Asc or Desc on this formula field (either sort direction should work)
Conditionally suppress the rows past the 20 you want to show (I also use a parameter to let the user determine the total number of rows to show).
 
I used a running total (e.g. #EmployeeCount) to do a distinctcount on employee id and suppression in the section expert using that.
{#EmployeeCount}>20
 
I do not know if the math on that formula works out to technically function as a pure definiton of random but it seems to works for what I needed.


Edited by DBlank - 09 Jan 2012 at 8:11am
IP IP Logged
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