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!

Top N summary 1

Status
Not open for further replies.

ddrake

Technical User
Mar 19, 2003
92
Hi,
I've got a report that displays the Top 10 of a particular grouping. For example, of a dataset of 100 entries all with different categories, I've grouped by that category field and I'm displaying only the top 10 results based on summaries of each category:

1. Category 1 - 10 records
2. Category 2 - 9 records
3. Category 3 - 8 records
4. Category 4 - 7 records
5. Etc.....

There are a number of records left over that are not displayed as part of the top 10.

My question is how can I get a total of just those top 10 without including the rest of the dataset?
 
Create two formulas:

//{@accumtopN} to be placed in the group header or footer:
whileprintingrecords;
numbervar sumtopN;
numbervar counter := counter + 1;

if counter <= 10 then
sumtopN := sumtopN + sum ({table.amt},{table.category});

//{@displaysumtopN} to be placed in the report footer:
whileprintingrecords;
numbervar sumtopN;

-LB
 
If I place the second formula in the Report Footer it works beautifully. When I place it in the Report Header however, it displays 0. How could I modify the second formula to be appropriately displayed in the report header instead?

Thanks!
 
To get this number in the report header, I think you would have to save the report under a different name, and insert the newly named report as a subreport in the report header of the original subreport, suppressing all subreport sections except the subreport footer.

-LB
 
Brilliant! Thanks a lot! [bigsmile]
 
That's what my first post describes, assuming you have already used the topN/group sort.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top