crystal reports how to show grouping only when a column/field has more than one values


I have a column in a dataset which can have two values val1 and val2. I want to group the records in crystal reports only if both values occur at least once in the records
rd1 a1 b1 val1
rd2 a2 b2 val2

but it should not show grouping if all the records have val1.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't really understand what you are asking.

This is my reading of what you have posted - and imagining there are say 100 recrods..

If all 100 records show the value Val1 in the 4th field then you do not want the records to be grouped in any way?

But if there is at least one val1 and at least one Val2 then you want the records to be grouped - but grouped on which field?  The field that contains val1 and val2?

If this is so then I think the solution will involve grouping the records on the val1/val2 field but  suppressing the group header and footer if there is only one group.

Can there be values other than Val1 and Val2?
Can all values be Val2?

Can you confirm the requirements and data content before we go any further.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Maverick_CoolAuthor Commented:
Your assumption is correct.
Groupin on the field contailin val1 and val2
all values can be val1 or val2 or mixed

please tell how to do this with formulas
when i tried this its suppresing grouping if all val1, but if it contain val2, then the val1 header text is not shown.

1. all val1
no groupin

2. atleast val1 and val2
val1 header text
val2 header text

3. all values val2
val2 header text
The only way I can think to do this is suggested by peter.

Add  a formula name - Val1Counter
If {Field4} = 'Val1' then

Group on the field

In the section expert conditionally suppress the group header with
Sum({@Val1Counter}) = Count({Field4})

Just thought of another way to suppress it without the formula

DistinctCount({Field4}) = 1

Based on your last example, you only want to suppress the group header if val1 is the only value.  If val2 is the only value, you still want to see the header.  Or, to put it another way, you want to see the group header if any of the records have val2 in that field.

 In that case, create a formula like the following (call it whatever you want):

if {field} = "val2" then

 Then use a formula like the following to suppress the group header:

Sum ({formula created above}) = 0

 That will suppress the group header if none of the records in the report have val2 in that field.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.