Solved

How do I hide a Group Header when the details are hidden due to a certain condition?

Posted on 2010-11-16
16
951 Views
Last Modified: 2012-05-10
I have a report which has data hidden in the Group Footer when a certain field sums to zero and also some other conditions are met.

My question is, how do I hide the Group Header?  (ie given that one of the conditions ie sum = 0 is only evaluated at the Group Footer stage).

Many thanks
0
Comment
Question by:spectrum17
  • 7
  • 5
  • 3
  • +1
16 Comments
 
LVL 8

Expert Comment

by:kingjely
ID: 34152409
Go to section expert.
suppress expert and tick suppress, on the header you want to suppress.

Go to formular X2

and put in

SUM ({YOURTABLE.FIELD}) = 0
(Where the above is your group footer field.)

Is this what you mean?





0
 

Author Comment

by:spectrum17
ID: 34152480
Thanks Kingjely, I have tried this by using the same suppression formula in the Group Header that is in the Group Footer, but I still have some Group Headers appearing.

Is this because the Sum = 0 isn't evaluated at the Group Header stage?
0
 
LVL 8

Expert Comment

by:kingjely
ID: 34152503
Hi No, It will still work.. I have tried it here.

From what i understand you want, If GFooter#1 = 0 suppress GHeader#1.. Right?

Whats your suppression formular? and are you definatly doing in on the group header.
Are you saing its working on SOME footers the =0 but not others?

Also are you sure, your making the judgement on Group HEADER #1 for Group FOOTER  #1 ?

0
 

Author Comment

by:spectrum17
ID: 34152610
OMG, what a moron I am!! I was using the formula from Group Footer 3 for Group Header 1. I'll try and move it to the right spot then report back.....
0
 
LVL 8

Expert Comment

by:kingjely
ID: 34152623
Hehe, no worries, I did that in my test for you.. trying ways to make it NOT work..
Thats why i suggested it :)


Let me know how you go..
0
 

Author Comment

by:spectrum17
ID: 34153523
Hmmn, well I went a lot better than before, but I'm still having a few records showing. This is the formula I'm using to suppress:

{?Sort}="Date" or

{#Qty Ord} = Sum ({ttdsls401300.t_qidl}, {@Ordersort}) or // ordered = delivered 
Sum ({ttdsls401300.t_qidl}, {@Ordersort}) > {#Qty Ord} or // delivered > ordered({ttdsls401300.t_sqnb} = Maximum ({ttdsls401300.t_sqnb}, {@Ordersort}) and {ttdsls401300.t_bqco} = 2 and {ttdsls401300.t_oltp} = 3)
 // last line of delivery + backorders confirmed = no + order type = backorder

Open in new window


Can you see any issues with it?
0
 
LVL 34

Expert Comment

by:James0628
ID: 34162867
I'm guessing that you lost a return there and everything after "// delivered > ordered" on line 4 should have actually been at the beginning of line 5.

 {#Qty Ord} is probably not going to work for suppressing a group header.  Running totals are accumulated as the records are read.  If {#Qty Ord} is a group total, it's going to be 0 in the group header.  It won't have the total until you get to the group footer.

 What is {#Qty Ord}?  If you can replace it with a regular summary function, you can use that in the suppression formula for the group header.

 James
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 34178575
Under normal Crystal naming rules {#Qty Ord} is a running total which isn't evaluated until the report is run and the final value isn't known until the group or report is complete.

mlmcc
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:spectrum17
ID: 34179451
Thanks everyone for your input. I've tried changing the 'Qty Ord' to a Summary field, but I still have Group Header fields showing that I don't want to see. Does anybody have any idea how I can hide these? The sum of the detail lines equals zero...
0
 
LVL 34

Expert Comment

by:James0628
ID: 34180304
It might be simplest if you could post your report so that we can take a look at it.  If you do that, let us know exactly which section you're having a problem with.  If you can save the report with some data, so that we can see the output from the report, that might be even more helpful, as long as there's nothing confidential.

 James
0
 

Author Comment

by:spectrum17
ID: 34182321
Here is the report I'm having trouble with. I need to try and hide the Group Header 1 when the conditions mentioned above are met.

Examples of the Group Headers that are appearing that I don't want to see are:

0574-141066
0585-141017
0585-738003
0593-016018
0593-640078

These Group Headers should be hidden as there is no data to go with it.



salesserviceLNexample.rpt
0
 
LVL 34

Expert Comment

by:James0628
ID: 34194504
FWIW, I see no saved data in that report, so those specific group numbers don't help.  If you meant to include saved data, you have to check the File > "Save Data with Report" option, run the report (if you haven't already), and then save it.

 I see a couple of issues with the suppression formula for GH1.

 Group 1 is on @ItemSort, but your GH1 suppression formula is checking Maximum and Sum for @Ordersort, which is group 2.  I'm honestly not sure what you're going to get from that, but it's a pretty safe bet that it's not going to work.

 Do you really want to suppress the GH1 header based on summaries from group 2?  Since each group 1 would normally be expected to contain multiple group 2's, which group 2 summaries are you supposed to use to suppress GH1?  And if each group 1 actually only contains one group 2, you could just use summaries for group 1 instead.

 You are also still using the {#Qty Ord} running total, which, as has already been mentioned, won't have a final total until the end of the group.  So, you normally can't use a running total to suppress a group header, but in this case there's the additional factor that, like the summaries mentioned above, it's a running total for group 2, but you're trying to suppress GH1, so it's also a running total for the wrong group.

 The good news is that that running total appears to be a simple maximum of ttdsls401300.t_qoor, so you could just replace it with Maximum, but there's still the issue of it being the maximum for group 2, but you're trying to suppress GH1.


 There is also another potential issue with the GH1 suppression formula.

 In addition to the summaries and running total for group 2, you're also checking some individual fields (eg. ttdsls401300.t_bqco = 2).  When you check those individual fields in the group header, you'll just see the value from the first record in the group.  If every record in the group will have the same value in that field, or if you're specifically interested in the value in the first record in the group, then that's fine.  Otherwise, you may need to change those individual field references to something else.


 Also, FWIW, I would uncheck the Suppress box on GH1.  You have the box checked and have a suppression formula.  Having both is not a problem, as far as CR is concerned.  The formula takes precedence.  I just find it a bit confusing that when you look at the report in the design view, the section appears to be unconditionally suppressed, because that box is checked.

 James
0
 

Author Comment

by:spectrum17
ID: 34194841
Hi James, thanks for your response. I've read through it all and thank you very much for your valuable input.

What I'm trying to achieve is to hide the Group Header 1 if there isn't any relevant info in the Group 2 section which lies underneath it. Group 1 could contain multiple Group 2's underneath it.

I've unchecked the Suppress box on GH1, and changed the formula which still had a reference to {#Qty Ord} (replaced this with the maximum formula).

I've attached the report again with the data saved.

Any ideas on how to achieve the suppression of Group Header 1? Many thanks!
salesserviceLNexample.rpt
0
 
LVL 34

Accepted Solution

by:
James0628 earned 500 total points
ID: 34195708
There's still the question of the individual fields that you're checking, like ttdsls401300.t_bqco.  Will those have the values that you're looking for in the first record in each group 1, or the last record in each group 2?  If not, which record(s) do you need to check?

 Ignoring that issue for the moment, I may have a solution.  The idea is to move your group 1 header from GH1 into a group 2 header or footer.  Normally I'd suggest a GH2 section, but since your current GH2 is suppressed and you're showing GF2 instead, a new GF2 section might make more sense in this case.  You use the same same conditions to suppress the new GF2 section, plus add a condition so that it is only displayed for the first non-suppressed group 2 in each group 1.  That last part was the tricky bit.  :-)

 I'm attaching a version of your report with my changes.  Note that you're using CR XI and I have CR 10, so if you used any features that aren't in CR 10, those will have been removed from my version.  Unless you're sure that there's nothing like that, you might want to try to incorporate my changes into your report, rather than just use the report that I'm u/l'ing.

 The basic changes are:

 I created a formula named init_var that declares and initializes a variable named g1_hdr_shown, and put that formula in the report header.  The formula only produces an empty string, so it won't show on the report, but you can suppress the field if you like.  For that matter, you could create a new report header section and put that formula in it and suppress the whole section if you like.

 I changed the suppression formula for GH1 to reset g1_hdr_shown for each new group 1 (replacing all of the old code).  That suppression formula always outputs true, so GH1 itself is always suppressed.  But first the formula resets g1_hdr_shown.  I originally tried resetting g1_hdr_shown in a formula that was placed in GH1 or GF1, but I could not get that to work.  I think it has something to do with how CR evaluates the sections as it's building the report, and things weren't being done in the required sequence.  But when I put the reset formula in the suppression formula for GH1, that seemed to work.

 I added a new GF2 section and put the group 1 name in that section.  The suppression formula for the new GF2 section checks the same suppression conditions used for the old GF2, plus g1_hdr_shown.  It also sets g1_hdr_shown based on the old suppression conditions.  If g1_hdr_shown is false (meaning that the group 1 header has not been displayed yet), and the old suppression conditions are false (meaning that the group 1 header is going to be displayed this time), then it sets g1_hdr_shown to true, so the next time through, it will know that the group 1 header has been displayed.


 One other thing:

 In the list that you posted before of group headers that you don't want to see, the last one in the list was 0593-640078.  But in the report with sample data, there _is_ a GF2 showing for that GH1, so I assume that you really do want to see it?  Just checking.

 James

salesserviceLNexample-J2.rpt
0
 

Author Closing Comment

by:spectrum17
ID: 34201826
Totally awesome solution James!! A++++
They don't call you a Genius for nothing! Thank you.
0
 
LVL 34

Expert Comment

by:James0628
ID: 34203055
You're welcome.  Glad I could help.  It was an interesting problem.  :-)  Resetting the variable really had me stumped for a while, until I finally tried resetting it in the suppression formula.

 James
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now