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!

Group Specified on a non recurring field - another twist

Status
Not open for further replies.

bbgbp

Technical User
Oct 15, 2003
4
US
I have a situation which I'm sure many people have run into:

My recordset contains items which need to be grouped by manufacturer status. If the status of a particular item is unavaiable but other items by the manufacturer are available, the manufacturer status needs to be set to available. However, if all the items by the manufacturer are unavailable, the status of the manufacturer should be unavailable.

I wrote a formula to do a distict count on the item status at the manufacturer level and compare that to the item status. If the distinct count > 1, the manufacturer status is set to 'A'. If the distinct count = 1 and item status = 'U', the manufacturer status is set to 'U'. Else the manufacturer status is set to 'A'. That all works fine.

Now for the twist. I need to group all the available manufacturera together and all the unavailable manufacturers together. I can't do this based on my manufacturer status formula because it uses the distinct count function.

There has to be a way to group based on a variable in Crystal. Does anyone know the way? Do I need a evaluation time function somewhere along the line?

Thanks in advance!
 
If you can create a SQL expression, create the following {%count}:

(select count(distinct AKA.`itemstatus`) from Table AKA where
AKA.`Manufacturer` = Table.`Manufacturer`)

Replace "Table" with your table name, and replace "itemstatus" and "manufacturer" with your exact field names. Leave "AKA" as is, since it is an alias table name. If you have record selection criteria, they may need to be built into the expression also.

Then create a formula {@Availability}:

if {%count} = 1 and
{table.itemstatus} = "U" then
"Unavailable" else
"Available"

You should be able to group on this formula.

-LB
 
Thanks for the post, LB.

I should have mentioned that I'm using Crystal 8.5. The report is being run off a single SQL stored procedure which is shared by other reports, so I can't change it to do this modification within the sp.

Any other ideas?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top