Here is one solution, if you can use SQL Expressions (might not be available in 7.0). First, create a regular formula {@group}:
if isnull({Demographics.Co_ID}) then {Name.ID} else {Demographics.Co_ID}
Insert a group on {@group}. This will cluster the parent and child company IDs together. Next insert a group on {Name.ID}. Then go to the SQL Expressions editor and enter:
(select max(AKA.`Date`) from Name AKA where AKA.`ID` = Name.`ID`)
Substitute your exact field names for "Date" and "ID". If your table is named "Name" then that's all you should have to change. Leave "AKA" as it is since it represents an alias name. The punctuation you need to use might vary depending on your datasource (I think).
Next go to report->edit selection formula->record and enter:
if {Name.ID} = {@group} then
{Name.Date} = {%max} else true
This will return only the maximum record for the {Name.ID}. Now go into your report and right click on {Demographics.TransportVolume} and insert a summary (sum) on it at the {@group} level.
Next go to report->topN/group sort->{@group} tab and choose "sum of {@group}" and choose ascending. This will now order your groups by summary amount. Drag the groupname into the group footer for {@group} and then suppress the details and GH2 and GF2.
While you can't create groups on these sums, you can give the appearance of groups by creating a formula like the following:
whileprintingrecords;
stringvar y;
stringvar z := z + y;
numbervar counter := counter + 1;
y := if sum({Demographics.TransportVolume},{@group}) in 0 to 10000 then "0 to 10,000" else
if sum({Demographics.TransportVolume},{@group}) in 10001 to 20000 then "10,001 to 20,000" else
if sum({Demographics.TransportVolume},{@group}) in 20001 to 30000 then "20,001 to 30,000" else
"30,001 or greater";
if instr(z,y) = 0 then counter := 1 else counter := 0;
y
Since your other fields are in the Group #1 footer, place this formula in the Group #1 header. Then go to the section expert->Group Header #1->suppress->x+2 and enter:
whileprintingrecords;
numbervar counter = 0;
This will eliminate the header for groups with the same heading, and will give the appearance of an outer group.
-LB