Search code examples
crystal-reports

how to suppress group header 1 if group header 2 is not showing anything


please help this noob on suppressing a group header 1 if group footer 2 is not displaying anything might be because there are no records to display, or all records are suppressed. I have a suppressed condition on group footer 2

IACode Group header #1 [Description] 
ICode  Group header #2
Details               | itemcode | date | aantal |   qty (supressed)
ICode  Group footer #2| itemcode | date | (SUM)aantal | SUM(qty) 
IACode Group footer *1

sample result
ABC Company (no data)
Helios Corporation     
     xx1001 09/10/2022 200 100
     xy2091 09/22/2022 125 099
Super Tech Company
     yy2222 01/10/2021 100 234 (suppressed as per suppress condition)

it should only show
Helios Corporation
     xx1001 09/10/2022 200 100
     xy2091 09/22/2022 125 099

current suppression condition @ x+2 of Group Footer #2
ISNULL({qty}) OR {@datum} > 90 OR {aantal} = 0 (this is the only formula for the suppression).
and for the formula datum is date('9/1/2022') - {table.date}.







Solution

  • You have to evaluate the fields within Group Header 2 while printing Group Header 1.

    So imagine a Crystal Report for inventory items. If I group my inventory items first on ITEMNO, and then on REVISION, I will have a report with ITEMNO in Group Header 1, and REVISION in Group Header 2. Then the details sections can contain other fields such as ONHAND_QTY, PRICE, STD_COST, ect...

    Not every item will have a REVISION, so there will be some NULL values in this field. If I wanted to suppress Group Header 1 when Group Header 2 contains no data, its easily done when the fields within Group Header 2 all contain NULL values. To do this I simply use the following formula in the Suppress property of the Group Header 1 section.

    ISNULL(GroupName ({ARINVT.REVISION}))
    

    If the REVISION field is NULL, this formula returns TRUE and suppresses Group Header 1. If you have multiple fields in Group Header 2, you will need to test each field for NULL values. Now the formula becomes:

    ISNULL(GroupName ({ARINVT.REVISION})) & ISNULL(OTHER_FIELD_1) & ISNULL(OTHER_FIELD_2)...
    

    Now the tricky part comes into play when you need to suppress Group Header 1 because Group Header 2's fields have all been suppressed and do not contain NULL values. In order to satisfy this requirement, you will need to create an aggregate of all of the formulas that suppress the fields in Group Header 2. And then use that same logic to suppress Group Header 1. Its hard to provide much of an example of this without full knowledge of how you are suppressing fields within Group Header 2. I'm willing to give it a try though if you can share all of the formulas used to suppress the fields in Group Header 2.

    Now you need to combine the formula for supressing Group Header 1 when all the fields in Group Header 2 are NULL with the aggregate of the formulas used to suppress fields within Group Header 2. This would roughly look like this:

    ISNULL(GroupName ({ARINVT.REVISION})) or [aggregate formula goes here]
    

    This formula should then return a value of TRUE if all of the fields are NULL or if all of the fields are suppressed within Group Header 2.