Print Page | Close Window

sorting random rows

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=8633
Printed Date: 01 May 2024 at 10:40pm


Topic: sorting random rows
Posted By: gerrym730
Subject: sorting random rows
Date Posted: 14 Dec 2009 at 1:49pm
INFO:
Rows are assigned a random number and selected via percentage of total row count.

The data is sorted by a random number, so I suppress the rows I do not want displayed. Sample below

Name                 Random Number     
=====               ============
John                         .01
 
Chris                        .24

George                     .34


... etc , ... , etc


Question:
After i have my data set selected and ordered,  how I do display the data in Name order?  Use an array and resort the data for display purposes (suppress display of first detail group and put in a second detail group)?


Thanks for any assistance









Replies:
Posted By: lockwelle
Date Posted: 15 Dec 2009 at 6:56am
Just to make sure that I have this correct, you sort the data so that you can suppress rows based on the random number.  Once the rows are suppressed you want to display the report in name order.
 
I guess my first question is how are you getting the data?  Since this is an application, I would think that you have access to the db and can create a stored proc, which is by far the easiest method to get data for a report.  In the stored proc, I would delete/omit the rows that would be suppressed, then just build the report based on Name.
 
Here's the problem, if you have a group that is based on the random number, and that is your highest group, then regardless of what grouping you add, it will first be sorted by the random number, so any subgroup would be for people with the same random number (which is unlikely).  If you can filter the data without the grouping, say in the reports/selection formula/records, then your grouping can be on the name.
 
Hopefully you can see how CR is applying the grouping, because once you can understand that, you can figure out how to make CR do what you want...or see why it can't be done.
 
HTH



Print Page | Close Window