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

Percentage of Top N 'without' a subreport?

Status
Not open for further replies.

Jcfx

MIS
Oct 8, 2004
134
US
Using CR 10, SQL 2000

I have the usual top N type of report where I had to show the sum of just the top N. Found the formula I needed on these boards.

Management then requested the percentage of top N, I had already created the subreport as suggested in the various threads here in anticipation of this request, but I am being told in no uncertain terms that they absolutely do not want to use subreports, even though the numbers are exactly what they requested.

Once you have your displaySumTopN formula, is there anyway possible to use that as a percentage without a subreport?



For those who may be looking, these are the formulas I've been using, as suggested by Lbass in various threads:


Code:
//{@accum} to be placed in the group header section:
whileprintingrecords;
shared numbervar qtysoldN;

if groupnumber <= {?N} then
qtysoldN := qtysoldN + Sum ({Qyt_Sold},{table.item});

//{@display} to be placed in the report footer section:
whileprintingrecords;
shared numbervar qtysoldN;

Then save your report under a different name--add "-subreport" to the title, for example. Then open the original report and insert the newly saved report as a subreport to be placed in the report header. In the subreport, suppress every section so that it is blank in the main report header. Eliminate the borders as well.

Then in the main report create a formula {@PercentofTotal}:

whileprintingrecords;
shared numbervar qtysoldN;

Sum ({Qyt_Sold},{table.item}) % qtysoldN

Place this in the group header section and format it as a percent by clicking on the percent icon in the toolbar.

-LB



Julie
CR 9,10 CE10 Sql DB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top