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

Find Top Seller

Status
Not open for further replies.

msay

Programmer
Aug 17, 2001
56
US
I have a table named sales that contains names of salesmen and their individual sales totals. What I need to output is the Top seller based on the total sales. I sub-totaled the table.totalsales field and tried to use the MAX function on a it, but that doesn't work. Any help is appreciated.
MS
 
Click on report, edit selection formula, group and enter a formula:

Sum(SalesAmount,Salesperson)=Max(SalesAmount,Salesperson)

This will return ONLY the top salesperson.

If you want a salesperson ranking report, use the TopN/Sort group expert under the report menu.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
This is the formula I used for a group on ado.salesman:
Sum({ado.totalSales},{ado.salesman})=Maximum({ado.totalSales},{ado.salesman})

It doesn't return anything. ????
 
It's a little unclear what the data is you are working with. Do you need to sum the {table.totalsales} field in order to get the total per salesperson? Or is {table.totalsales} already a sum by salesperson? If we assume that it needs to be summed by salesperson and then you have to determine which salesperson's total is the highest, you could just do a TopN on the summary field and select 1 as N.

If {table.totalsales} is already a sum by salesperson, then you could do a group select to bring back only the record with the highest sales amount and corresponding salesperson:

{table.totalsales} = maximum(table.totalsales}

-LB

 
Since you have a subtotal, use the TopN feature and set N to 1.
if you are in v9 TopN is called group Sorting.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
You cannot Group on a "Summary function" ....use Top N as Ken suggests

Jim Broadbent
 
Thank you!!! Top N with N set to 1 works like a charm.
Mike Sayler
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top