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

Need Top N Help 1

Status
Not open for further replies.

Bennie47250

Programmer
Nov 8, 2001
515
US
Crystal Version 7.0

Need help getting the Top 10 to work.

Our table has Operation Number, Part Number, Problem Code and Qty produced.

Need to know the sum of the top 10 qty produced when grouped by Operation Number, Part Number, and Problem Code

The report I have generated has 3 groups,
Group 1 = Operation Number
Group 2 = Part Number
Group 3 = Problem Code

The only subtotal I have is the sum of qty produced for Group 3

When I run the report, I have over 1700 subtotals. Now I only want to see the Top 10. How can I do this?

Thanks

Bennie
 
If you use TopN on Group #3, you will get the top 10 subtotals for Group #3, within each instance of Group #2. If you are really looking for the top 10 instances at the Group #3 subtotal level across all groups, then try concatenating the three group fields, as in {@concat}:

totext({table.operno}))+totext({table.partno})+{table.problemcode} //remove totext() if fields are strings

Remove your original groups and instead insert a group on the formula above. Insert a summary and then choose topN for this group tab.

As for adding the topN subtotals, create two formulas:

//{@accum} to be placed in the group header or footer for {@concat}:
whileprintingrecords;
numbervar x := x + sum({table.amt},{@concat});

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

-LB
 
lbass, you are the best, concatenating the three group fields did the trick. Never would have thought of that.

Not sure what I need the other two formulas for thou.

Thanks
Bennie
 
You said you needed the sum of the top 10. If you insert a grand total, it will include the subtotals of those groups not in the top 10. The formulas above allow you to display the sum (a running total) of the top 10 only.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top