Print Page | Close Window

Group by Parameter Nth Top Qty?

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=5646
Printed Date: 04 May 2024 at 8:11am


Topic: Group by Parameter Nth Top Qty?
Posted By: Debbie Giles
Subject: Group by Parameter Nth Top Qty?
Date Posted: 02 Mar 2009 at 1:56am
I am trying to Group by a formula.  I want to be able to select a number eg. 300 to be my top Nth Qty group by.  I cannot figure out the formula I would enter into the Group by formula.  Rgds
Debbie


-------------
Debbie Giles
Syspro Consultant
EOH
+27 21 525 7200



Replies:
Posted By: lockwelle
Date Posted: 02 Mar 2009 at 6:42am

I don't know if you can do that as it can not be determined by looking at the data, ie that information is not inherent in the data. If you just want to print the first 300 records of a group, I can see how that would be done, maybe it is just wording issue.

If you wanted the first 300 records in a group, I would create a formula to be run in the details that is just a counter:
shared numbervar iCount := iCount + 1;
""  //hide the number
 
then in the details section expert, I would conditionally suppress the row if iCount >300
 
there would be a last formula to set iCount :=0 in the group header.  If any calculations are to be performed on the data, you would need to add them in the detail formula or perhaps a running total would work, but I don't use them too often so am not an expert on them.
 
Hope this helps


Posted By: DBlank
Date Posted: 02 Mar 2009 at 6:56am
If you are looking for the top groups rather than the top records per group (lockwelle answers this for you) and you want the Top N to be selected at run time:
Create a Parameter as "Top N Selection" as a number and Enter in any Min and Max restrictions you want to apply.
Set up your Group and summary function (count or distinct count or Sum or whatever you are defining this top values on).
Go to the Group Sort Expert (the graph with teh up arrow on it).
"For this group sort" select "Top N".
"Based on" will be your summary value you defined earlier.
"Where N is" use the formula editor and insert: {?Top N Selection}
You can choose how to handle the other items as needed.



Print Page | Close Window