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!

Top 5 selection

Status
Not open for further replies.

nikol

Programmer
Apr 12, 2005
126
US
Hi ,
I have a table with more then 50 Zipcodes & Client (UID's).
Zipcodes UID
96745 10
95051 9
96457 6
98657 4
96234 4
TOTAl -----
33
------
I only want TOP 5 ZIPCODES with DESC UID. I got the TOP 5 Zipcodes thro "GROUP SORT EXPERT". HOW can I get the Total of only TOP 5 ZIPCODES ie 33..
 
Create a formula to be placed in the group section:

whileprintingrecords;
numbervar top5zip;
numbervar cnt := cnt + 1;

if cnt <= 5 then
top5zip := top5zip + distinctcount({table.UID},{table.zipcodes});

Then place the following formula in the report footer:

whileprintingrecords;
numbervar top5zip;

-LB

 
Why wouldn't a standard running total work in this situation?
 
Because the values for UID are a summary field (note that the poster is using a group sort), and summaries are not available in the running total expert.

-LB
 
Right, but if you were to do the running total on the same field that is being used for the summary in the grouped section but placed it in the report footer it would only sum/count the records that were included in the top 5 groups. This works because of the evaluation time of the running total.
 
Okay, you are right--as long as the summary can be evaluated at the record level (and it can in this instance). I was thinking erroneously that topN behaved as if suppression of the other groups occurred, but instead it is more like group selection. With suppressed records, running totals have to remove the suppressed records, while in group selection this is not an issue. An inserted running total can't reference recordnumber or groupnumber, and that was why I used the manual running total.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top