Suppress Section if Field is Null

daskas27
daskas27 used Ask the Experts™
on
Hello,
      I have a report that is grouped by Customer, then Engine Program, then Part Number. I would like to suppress everything for the Engine Program and Part Number sections if the Engine Program field is null. In other words I only want to see results if there is a value in the Engine Program field. Can this be done.
I have attached a copy of the report in case it helps.

Thank you
example.rpt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
If the engine field is null you won't get  a group for it.  It is automatically suppressed.

mlmcc
Nontheless CR might react irregular on dbNull values ... and besides of that it ist probably more self-documenting to cast that behaviour into some formula.

In the formatting formula "suppess section" of the two sections you could enter:
IsNull({engine})

Open in new window

That would suppress these sections when "engine" is dbNull without CR freaking out on the value. (the field name might differ in your report ... :)

Furthermore you could insert another section telling "No engine defined" and garnish that with a suppress formula
not IsNull({engine})

Open in new window

to inform the reader about the condition (that behaviour can't be realized with the default outlined by mlmcc ...).
It's been a while, but, contrary to what mlmcc said, I don't think CR suppresses a group if the field is null (I'm pretty sure I've seen a report with a group for a null field).  I would hate to think that CR would just remove a whole group from the report because the group field was null.

 The "Engine Program" field that you're referring to is tcspnm.pohspec, correct?

 Is pohspec actually null, or is it just blank?  Those are two different things.  In your example report, that field is sometimes blank, but it's never null.

 What do you want to "suppress"?

 If you want to get rid of the entire group, including the details, the simplest thing would be to go into the record selection formula and add

and {tcspnm.pohspec} <> ""

 That's assuming that the field is actually blank, not null.

 If the field actually can be null at times (not just blank), you could add

and not IsNull ({tcspnm.pohspec})


 That will remove any records where pohspec is blank (or null in the second case) from the report completely, so they won't be included in any summaries either.

 For the record, instead of using the record selection formula, you could suppress the desired sections when the field was blank (or null), but then the report would still be reading those records and they would be included in any summaries.

 James
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

daskas27IT manager

Author

Commented:
Ok, what if I did not want to suppress it but have a label like "UnKnown" instead of the blank if the the tcspnm.pohspec field is blank or null ?
Ok, what if I did not want to suppress it but have a label like "UnKnown" instead of the blank if the the tcspnm.pohspec field is blank or null ?
I've outlined that in my first response ... you create a separate section with only that text "Unknown" in it.

In the suppression formula of the "regular" section you use
isNull({tcspnm.pohspec})

Open in new window

which suppresses that section if that fiels is dbNull. If you want to catch blank strings too, you could use
isNull(tcspnm.pohspec}) or (trim({tcspnm.pohspec}) = "")

Open in new window

For the "irregular" section to be displayed if tcspnm.pohspec carried dbNull (or a blank string ...) you enter  the respective negated condition
not isNull({tcspnm.pohspec})

Open in new window

or
not (isNull(tcspnm.pohspec}) or (trim({tcspnm.pohspec}) = ""))

Open in new window


Quite simple, isn't it ?
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
If you have a record but a field is NULL then frankhelk's method will work since the group will show as nothing.

My comment was thinking along the lines of joined tables where since there was no engine number the rest would also be null.

mlmcc
frankhelk's ideas should work, but if you simply want to change the displayed value for tcspnm.pohspec, there are simpler solutions.

 It seems that the field is actually blank, instead of null, but you can go ahead and check for both.  Create a formula like the following (call it whatever you like):

if IsNull ({tcspnm.pohspec}) or {tcspnm.pohspec} = "" then
  "UnKnown"
else
  {tcspnm.pohspec}


 If there is more than one pohspec for a customer and you want the "blank" one first, just put that formula in the pohspec group header, instead of the group name.

 Or, you could change the group to use that formula, instead of the pohspec field, and then the "blank" pohspec will be replaced with "UnKnown", and you'll get an "UnKnown" group at the end of the customer.

 James
daskas27IT manager

Author

Commented:
Thanks to all.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial