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

Sorting on a group-field 1

Status
Not open for further replies.

Flupke

Programmer
Jun 26, 2002
94
0
0
BE
Hello,

In my report, I want data grouped on a Person_id.
However, I want the data sorted on the Person_name.
How can I achieve grouping on an ID and still sort on the NAME?

Many thanks and greetings from Bruge (Bruges - Belgium),

Michel
 
Group on the name...

Grouping performs sortation in Crystal, as with most SQL languages, so your post doesn't make sense, how could something be grouped/sorted one way, yet grouped/sorted another way at the same time?

Perhaps you aren't conveying requiremetns clearly, try posting example data and the expected output instead of writing about it.

-k

 
You can either insert a group #1 on name and a group #2 on ID, or what I often do is create a formula {@namesort} that concatenates the two:

{table.name}+totext({table.ID})

Insert a group on this and then go to options->customize group name->use a field->choose {table.name}. The formula ensures that if you have two people with the same name, they will each appear.

-LB
 
lbass: How would your solution provide for grouping on the ID?

It will be grouped by the name, and then the ID, not grouped by the ID.

-k
 
I haven't tried this, but there is another sorting option in the Group options.

If your data that Crystal is reading is already sorted in the order you want, you can choose 'in original order' in the Group Options dialog.

If you can't pass the data in the order that you want, or this does not work the way I am interpreting it, then I think lbass' solution should work. I'm assuming you don't want to group on name as there may be more than one ID with the same name, since names are not unique.
 
If the intent is to aort by name, but uniquely qualify each name, then lbass's method is correct, however the post asked for grouping by ID, which is also a sortation.

Of course a formula concatenating the two will work, as would creating 2 groupsin that instance.

bmarks: In original order would mean that you'd need to sort the data on the database by the name and then the ID. Lbass's method is correct, and commonly suggested, I just took issue to the poor description of the requirements, it should have stated that they want the report grouped by the name, yet preserve the uniqueness based on the id to llow for duplicate names.

-k
 
I do this all the time for customer reports I manage. Here is how if I understood you correctly. Otherwise it will benefit someone.

In Group1, select to group by customer ID (If you hold the mouse on the Group Header1, the tooltip says "Group Header #1: CustomerID"

Put the Customer Name field on the Group Header area.
Right click on it and select Insert | Summary...

In the dialog that appears, make sure the "Choose the field..." is CustomerName and the "Calculate this summary" is Maximum. The location to insert the field is Group Footer 1.

When the new field is insert, suppress it.

Click on Report menu and select Group Sort Expert... and verify that the "Max of CustomerName" is in the listbox. Change the radio option below it to Ascending. Click OK.

If you use Group Tree, then right click on the Group Header of the report and select Change Group Options. Click on Options tab, check Customize Group Name. Then select CustomerName from the combo box.

HOpe that helps. I haven't done it for awhile. But that is by checking one of the reports. I think I got it covered. Otherwise I am close.
 
DeafBug, Great solution. I don't use the Group Sort Expert much, so I forget about it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top