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

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.
3 Solutions
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.

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.

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.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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