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!

Sort records by a Sum field 1

Status
Not open for further replies.

hermantb

Programmer
Aug 30, 2002
18
US
As far as I can tell in looking through old posts it isn't possible to specifically sort by a SUM field, but is there any way of accomplishing that? I basically have a listing of accounts and the SUM of their orders but want it to show the highest orders first and sort descending.

Any help is much appreciated!
 
Use the TopN/Sort Group expert, under the report menu, to accomplish this. Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
The Nsort sort of works...let me see if I can better explain my situation. For instance these 2 columns, with the same account name possibly more than once if they ordered more than one product type. Quantity is a sum of orders based on type. I want the highest quantity on top and descending as shown below for example.

Account Order Type Quantity

Acme truck 1000
Federal truck 900
Acme car 850

Using the Nsort keeps Acme together...Any advice?
I currently have account and order type as groups with Quantity as a sum field and the details of the report hidden to get my results.

Thanks!
 
Instead of 2 group levels, make your primary group a formula that appends Account + Order, that way ACME will be treated as two separate groups. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Ken,

That was helpful and did exactly what i was trying to do! While TopN sort does sort SUM fields, it did not allow the groupings to be listed on seperate lines as in my example.

ie: it did this...

Acme truck 1000 (highest order total account
Acme car 850 (and sorted by type...but Giant
(should be next instead of Acme
Giant car 965 (car which should be the 4th
(record
Federal truck 950
Fedral car 10

 
If that is what you got, then you didn't do what I wanted you to do. Let me clarify what you should do to get your desired result. Your primary group should be the formula (to be safe make it your ONLY group). Then create a summary (SUM) for this group, and TopN using this group based on this sum. It should do exactly what you want.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
My note was confusing...The result in my last note was using 2 groups and the TopN sort. Using a Formula of Account and order type as the only group and using the TopN worked like a charm and gave me results like the third post in this thread...

Thanks,
TH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top