Crystal Reports 2008: Suppress Group Header when details are suppressed

11,915

Solution 1

For the sake of illustration, I'm going to assume that the logic to suppress your Details section is contained in the formula {@SuppressDetails?}. Now, create a new formula that outputs a 1 when the section is suppressed and a 0 otherwise:

if {@SuppressDetails?} then 1 else 0

Place this new formula in the Details section and suppress it. Now, create your Group Header suppression formula such that it compares the number of suppressed Details sections to the total number of records in that group (that is, the {table.MeterNumber} group):

count({@SuppressDetails?},{table.MeterNumber}) = sum({SuppressDetails?},{table.MeterNumber})

Solution 2

I actually found my own way to do this which I now prefer. It's very similar to the one @ryan posted.

I first created a formula field that returns a 1 when the condition is met and I set the condition to the same condition for the detail level suppression. I put that field on the detail level and I suppressed it.

I then created a summary field that sums up that field over the group. And put that field in the group summary and suppressed that too. I then added a suppression rule to the group that said if that summary field is less than 1 then suppress the group summary too.

Viola

Share:
11,915
razielxx
Author by

razielxx

Updated on November 16, 2022

Comments

  • razielxx
    razielxx over 1 year

    I have a report that currently displays data in the following format:

    GROUP HEADER
    January      Meter Number      Name       Class      Facility ...
    ...
    December     MeterNumber       Name       Class      Facility ...
    
    GROUP HEADER
    January      Meter Number      Name       Class      Facility ...
    ...
    December     MeterNumber       Name       Class      Facility ...
    

    I have a conditional suppression formula on the details lines that will suppress a record if one of the fields values is higher than a specific value. Everything works great if I suppress the Group Header line, but I just get a long list of the records that are not supposed to be suppressed. I would like to leave the Group Header visible so the report is easier to read. The problem is that when I add the conditional suppression formula to the Group Header line, it only looks at the first record in the group. If that record is suppressed, then so is the Group Header, but there may be 3 months worth of records that are not supposed to be suppressed so I would still like the Group Header to display. Instead what I get is the following:

    March      10003      Name       Class      Facility ... //Notice no Group Header
    April      10003      Name       Class      Facility ...
    December   10003      Name       Class      Facility ...
    
    Group Header
    January    10004      Name       Class      Facility ...
    March      10004      Name       Class      Facility ...
    February   10005      Name       Class      Facility ...   //Notice no Group Header
    March      10005      Name       Class      Facility ...
    

    Due to the January month being suppressed for meter number 10003 and 10005, the Group Header is also suppressed. I tried placing the Group Header on the details line and that works in the since that it prints the Group Header on every line but then I format that field and suppress duplicates and it does the same thing all over again. It only displays those Group Headers where the January record is not suppressed. This wouldn't be such a big deal but I am dealing with 1000+ records after the suppression.

    I have searched for two days for a solution to no avail. Is there any way to look at all records in a group instead of just the first record when it comes to suppressing?

    EDIT: For those questions as to why I need to suppress the Group Header when all of the details in that meter are already suppressed it's because if I don't then I get the following:

    10003
    10004
    January    10004      Name       Class      Facility ...
    March      10004      Name       Class      Facility ...
    10005
    February   10005      Name       Class      Facility ...   
    March      10005      Name       Class      Facility ...
    10006
    10007
    10008...
    

    In other words, I will get a few pages of just group headers before I see one with actual details.