• Status: Solved
• Priority: Medium
• Security: Public
• Views: 614

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

Hi,

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
Example
rd1 a1 b1 val1
rd2 a2 b2 val2

but it should not show grouping if all the records have val1.
0
Maverick_Cool
3 Solutions

Commented:
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.

0

Author 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.

scenarios
1. all val1
no groupin

2. atleast val1 and val2
records......
records......

3. all values val2
records....
0

Commented:
The only way I can think to do this is suggested by peter.

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

Group on the field

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

mlmcc
0

Commented:
Just thought of another way to suppress it without the formula

DistinctCount({Field4}) = 1

mlmcc
0

Commented:
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
1

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.

James
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Featured Post

Tackle projects and never again get stuck behind a technical roadblock.