Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Choosing every Nth record to create a "random sample"

Posted on 2013-01-28
5
Medium Priority
?
1,136 Views
Last Modified: 2013-01-29
Is there a way to chose every Nth record in Crystal Reports?  I need to perform an audit where I need to generate a sample population from over 22,000 records.  I would like to create a formula  that only displays every 35th record in order to create a sample size of closer to 640.  I need a sample from all parts of the records, so the Nth percentile, or Nth smallest or largest wont work.  I have done similiar things in Excel, but I am asked to do this a lot and I would like to do it in Crystal with out exporting it.  Any help would be appreciated.  I am using Crystal Reports XI.
0
Comment
Question by:josslmpd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 18

Expert Comment

by:vasto
ID: 38829221
Better do this on the database side. Then instead of 22000 records you will download just ~600. Your report will be 35 times faster. What is your database type?
0
 

Author Comment

by:josslmpd
ID: 38829239
It is a SQL server database.  I was hoping to do it in crystal since I am already running a selection fromula against the data to get it to the 22000 records.
0
 
LVL 3

Expert Comment

by:contactnaeem
ID: 38829540
Best option to do this at database level but if your requirement is at report level then you can hide or show records based on evaluation formula. Have a look at below link

http://msdn.microsoft.com/en-us/library/ms225351(v=vs.80).aspx
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 1000 total points
ID: 38830127
To suppress everything except every 35th record you just put this into the Suppress conditional format button in the Section Expert.

Recordnumber mod 35 <>0
However, if the report contains any standard  summary totals they will still include  ALL of records meeting the record selection criteria  (they will not change to reflect the reduced number of records actually displayed).  If you want totals to be correct you will have to change the way they are calculated.
0
 
LVL 23

Accepted Solution

by:
Ido Millet earned 1000 total points
ID: 38830696
Here's an FAQ I wrote about this many years ago:

Displaying a Random Sample
faq767-3260

If you need to randomly select and display a given number of records, or a user-specified proportion of the records, here's a simple approach:

Step 1:  
Place the following formula (@Random_Number)
in the detail section:
---------------
Rnd()
---------------

Step 2:
Sort the records by @Random_Number  (ascending).

Step 3:
In the suppress attribute of the detail section enter the following expression:

3.1 If you need to display a given number of Records:
----------------------------------------
RecordNumber > {?Show_N_Records}
----------------------------------------
where {?Show_N_Records} is a parameter allowing the user to
specify the number of records to be shown.

3.2 If you need to display a given proportion of Records:
----------------------------------------
RecordNumber > ({?Show_X_Percent}/100) * Count({some_field})
----------------------------------------
where {?Show_X_Percent} is a parameter allowing the user to
specify a number between 0 and 100.

Cheers,
- Ido
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question