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

% Sampling in Crystal HELP!!

Status
Not open for further replies.
Feb 24, 2005
19
US
I need to produce a report that will pull a 10% random sample for a specific date range chosen. I am pulling this info. from an Access DB via ODBC link. Could someone please help me with how to do this??

Thanks,
Scott
 
I can't get that formula to work, could you explain in more depth or give me other suggestions. I am a Crystal novice and for some reason I keep getting an error in the formula.
 
Which formula? Remember, you should have two:

The text of the first formula should look like this, and be placed into the Details section:

[tt]Rnd()[/tt]

The second formula is used as a suppression formula for the Details section, and to get 10% of the records, it would look like this:

[tt]RecordNumber > .1 * Count({YourTable.OneOfYourFields})[/tt]

-dave
 
So you're saying I put Rnd() as text in the detail section? or input that formula in the detail section through the Selection Expert and key it off of one of the DB's fields?
I understand how to supress in the formula editor, but if I want to get 10% of a date the user chooses how do I do that? If I just keyed it off of TradeDate it would give me 10% of trades on every date correct?
 
The two formulas required for this to work have nothing to do with the Select Expert. The only thing you need to use the Select Expert for is to filter your records by date. Once that's in place, here is what you need to do, step-by-step:

1) Create a new formula field named 'RandomNumber', with the text of:
[tt] Rnd()[/tt]
2) Drag the newly created @RandomNumber formula field into your Details section. This will generate a random number between 0 and 1 for each row.
3) Invoke the Record Sort Expert, and sort the report by the @RandomNumber formula
4) Enter a suppression formula like the following for the Details section of the report - it doesn't matter what field you use - to display a 10% sampling of the records that match your TradeDate criteria:
[tt] RecordNumber > .1 * Count({YourTable.OneOfYourFields})[/tt]

-dave
 
I followed your instructions word for word but nothing seems to happen. What is the tie between the random numbers and supressing the trade field to show 10% of the trades for the date range selected?

I must be missing something.
 
You should be entering the suppression formula in the section expert. Go to section expert->details->suppress->x+2 and enter it there.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top