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!

How to group/ungroup conditionally?

Status
Not open for further replies.

draii

Programmer
Mar 1, 2007
1
I would like to know if it is posible to group/ungroup a group with a condition. For example, if I have the the table x with the fields account, zone, gr_flag and amount. I have Group 1 that is grouped by x.zone. I would like to be able, based on the x.gr_flag, to "activate" the group when the flag is equal to 1 and to show the detail when the flag is equal to 0.

I have tried using the "Suppress" option in the group sections but the data only seems to be detailed but the grouping still occurs.
 
Depending on your version of Crystal, you should have Report > Selection Formulas > Group.

Or you could suppress the unwanted records in record selection, if you don't use them for something else.

It always helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever. Methods sometimes change between versions, and higher versions have extra options.



[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Try a formula like this to group on:

if {x.gr_flag} = 1 then
{x.zone}

Then you could conditionally suppress the detail section using this formula:

{x.gr_flag} = 1

This should return only the group level for flag = 1 and the details for flag = 0.

-LB
 
You can group on an IF-THEN formula.

if x.gr_flag = 1
then x.zone
else ""

That way when the 1 occurs there is a group, but all the records are in the same group, so now your sort will take over and reorder the records.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top