on 10-08-2008 8:45 PM
I am wondering if anyone has any tips on using Crystal to randomly select a certain number of records that fit within some designated parameters.
What I am wanting to do is create a report that randomly lists 10 incident numbers for every user that has incidents closed within a certain date range. The date range is 2 parameter fields.
You can use CR to display a random sample of records. Here's how I do it....
1) Create your report laying out the fields in the format you need, record selection parameters, etc. To display X records per user, group on your user field. You can supress your group header and footer and just display the details, if you want.
2) Create a formula field, I'll call it RandomNumber to illustrate. The contents of the formula should be: rnd()
3) Include the RandomNumber formula field in your detail level, you can hide the field so users don't see it.
4) In your Record Sort Expert, sort ascending on your @RandomNumber formula field
5) Add a Running Total Field (I'll call it RecordNumber) to your detail level. Field to summarize: @Random Number // Type of summary: count // Evaluate: For each record // Reset: On change of group - Group #1: Username. You can hide this field too.
6) In the Section Expert for the Detail section, create a conditional Supression formula - click the X-2 icon to the right of Supress (No Drill-Down). For the formula, enter {#RecordNumber}>X where X is the # of random records to display per user. If you want the users to select the # of random records to display, create a NumberOfRecords Parameter Field which prompts the user to enter the # of records to display and set your formula to {#RecordNumber}>{?NumberOfRecords}
That should give you what you're looking for. What this does is.... The @RandomNumber field will assign a randomly generated number to each row. You sort by this field to randomly order records. You count each row per user and hide all rows where the row number is greater than the number of random records you want to see.
Hope that helps and works for you.
Deb
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am currently trying to set up a barcode to a randomly generated number. Can someone briefly explain how I do this? I am currently using:
BarcodeC39(RND()*100000) but this is not working. It is asking for a string?
Any workable suggestions would be appreicated.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not familiar with the syntax for the BarcodeC39 function, but from the error, it sounds like it is looking for a string, not a number and the rnd function is passing in a number.
Have you tried barcodeC39(totext(rnd()100000))? That will convert the random # you have generated to a string. Note, the random # you generated may have a decimal. If that causes problems in the string, to format the # as a string without the decimal, try barcodeC39(totext(rnd()100000,"#"))
I already knew this, but thanks though.
I don't want random numbers selected I need random "incidents" selected from within a specific set of parameters. Rnd does nothing for me here so this is just something that crystal is obviously incapable of doing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anthony,
You are correct that Crystal cannot go out and grab records randomly. It's designed to read records based on the criteria or query you pass back to the database.
For something like what you want, a front end would have to be designed as another table that you've pre-populated with a random set of records so you can pull them into a parameter.
Good luck,
Brian
Crystal has a RND function that will give you a random number. You can experiment with that and see how you can apply it to your Incidents.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.