Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress a section with condition

Status
Not open for further replies.

alvintse

Programmer
Aug 1, 2003
66
US
I have created a report with CR9, detail as below:

Group1:name
Group2:Category ; total 6 categories(A,B,C,D,E,F in accsending order)
Group3:description

Report layout"

Group1 Header: name
Group2 Header: [Category description]
Group3 Footer: [Product Description] [amount]
Group2 FooterA: Total of [amount]
Group2 FooterB: Total of [amount] for Category A,B and C.

My problem is I only want Group2 FooterB appears:
after C if A and B existed
after B is only A & B
after A if only A or not shows up at all. (not all Category has data for the report)

I have tried to create a global var at Group2 Header to get all the header2 name:

if len(Category ) > 0 then
Category = Category & "," & GroupName ({table.Category })
else
Category = GroupName ({table.Category })
end if

and use the split() to find out what the next GroupName is and use the result as condition suppress.

It doesn't work because I can't get the next groupName before the report pass throught the current group.

I know I can use a subreport to get the information. I am not allow to use subreport because of the performance issue.

Any idea?

Thanks.


 
Hi alvintse,

Without actually testing it - have you tried using a shared variable instead of a global (they are the same but shared forces it to be evaluated much later in the reporting passes) - and - have you tried storing the group names in a string array? It is much easier and neater.

Your Group Footer B problem sounds like you are trying to display report footer information in an upper group based on data - without a subreport - unlikely - but surely a subreport that fetches groupnames cant be too much of an overhead.

Sometimes I find that suggesting to your superior that a stored proc might be in order - suddenly makes subreports tolerable - as they dont want to either write to stored proc or pay for someone to do it.

Anyway - I hope this helps you!

Cheers,

paulmarr
 
I think what you need to do is insert another group as follows:

Create a formula {@ABC}:

if {table.category} in ["A","B","C"] then 1 else 2

Group on this formula, and then go to report->change group expert and use the arrow key to make this group 2 (between your name group and category group). Insert a sum for the new group (to get the total for ABC) and place it in the new group 2 (ABC) footer. Then go to format section->Group 2 (ABC) footer->suppress-> and enter:

{@ABC} <> 1

Suppress the Group 2 header also.

-LB
 
Shared and Global variables aren't the same. A Shared variable is used to pass data between reports, a Global (which is the default for a variable), is used to expose a value throughout a report, and local means local to a formula.

Rather than posting text descriptions, it's much simpler to convey a need by posting example data and expected output. Aside from a seemingly language barrier, you also

This:

&quot;My problem is I only want Group2 FooterB appears:
after C if A and B existed
after B is only A & B
after A if only A or not shows up at all. (not all Category has data for the report)

Didn't clarify anything for me... Perhaps you're trying to say that you only want totals for C if there are totals for A and B, and for B if there are totals for A?

But the use of the term After throws me.

You might try using a Running Total with whatever criteria you want in the Evaluate Use a Formula area, or you might try posting meaningful examples and include the version number.

-k
 
synapsevampire is right about Shared and Global variable - in a way. Yes - a shared variable can pass values between reports and global within a report - but my point was that a shared variable is evaluated at a different time to a global variable.

The question at hand was that the global variable couldn't show the value of the groupname because of when it was evaluated. (what report pass) Shared variables are always evaluated later than global variables.

If you are an experienced Crystal person - you would agree that the only reason not to use a shared variable is if you use the same variable name somewhere else unrelated on a report or subreport - otherwise shared variables are always preferred to global.

Cheers,

paulmarr
 
Paul,

Shared variables are not &quot;always preferred to global&quot;. Shared variables and global variables are not interchangable. Shared variables make variables accessible between sub and main reports. Global variables are for exclusive use per report.

Evaluation time is controlled with functions like WhilePrintingRecords, EvaluateAfter, WhileReadingRecords, etc, as opposed to declaring variables incorrectly.

Naith
 
To Naith and synapsevampire,

As a former Crystal Decisions Instructor - we went into great lengths during training to come to the &quot;shared variable conclusion&quot;. I defy you to fill a shared variable with Whilereadingrecords!

paulmarr
 
Paul: What does that have to do with your statements that they are the same? They're not, which Naith also explained, and hitting F1 will help with.

Your analysis of the problem was suspect, if it was the result of it being at the reading pass, hence your mentioning shared variables, Crystal would have errored, not returned erroneous data. Note that they were using a GROUPNAME, which would NOT evaluate at reading level and hence toss an error when the formula was attempted to be created. So your own argument is what demonstrated your theory incorrect.

This place is littered with current and prior CR instructors, and real world large project architects/developers, 3rd party product developers, in general, a very competent lot - trying to impress people on that level may be pishing upwind hereabouts ;)

You sound like a knowledgable Crystal person, and I certainly make my fair share of *suspect* judgements, we always need more knowledge, and fresh perspectives are key, so don't take my statements the wrong way - welcome.

-k
 
PaulMarr - I take issue with this statement

If you are an experienced Crystal person - you would agree that the only reason not to use a shared variable is if you use the same variable name somewhere else unrelated on a report or subreport - otherwise shared variables are always preferred to global.

Are you suggesting that using &quot;Shared variables&quot; are preferred over Global (default) variables in a normal (non-subreport) report??

As a former Crystal Decisions Instructor - we went into great lengths during training to come to the &quot;shared variable conclusion&quot;.

Frankly if this is the type of instruction you were given it is no wonder why these Crystal forums are so popular, IMHO.

I defy you to fill a shared variable with Whilereadingrecords!

Hmmm...I venture to say I have never used WhileReadingRecords in my 10 years of Crystal reports experience. EXACTLY how does this function apply in this SPECIFIC in this problem???. And if it were simple initialization of a shared variable I don't see a problem with that....since there is no sorting or grouping of the data during this PASS through the data I hardly see the point of doing that.

Sorry....as a very experienced Crystal person....the ONLY purpose for &quot;shared variables&quot; is to exchange info between Subreport and Main report....otherwise I suppose they act the same as a global variable....

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Hi guys,
Thanks for all your advises. I took lbass's suggestion and created a formula and grouped with:

Group(A,B,C)
Group D
Group E
Group F

after group1 and do other grouping as before. Suppress group2 header and place the total at group2 footer.
This way I can suppress the group footer if group name <> Group(A,B,C).

Thanks.
 
To Ngolem and Naith,

I find both of your responses offending as well - and also note it was neither of your answers that even attempted to help the question at hand.

Neither of you offered any other information concerning variables that you wouldn't find in the CR help files.

Seeing as you both call yourself programmers - perhaps you could think outside the help files to determine why there are local, global and shared variables, and where they are stored in memory. If a variable was truly global - then why can't other reports access it?

My point I was trying to make was that different variables get evaluated at different times - not the differences in CR's definitions of variables.

Although I find this forum extremely useful and worthwhile - and also most of the tipsters answers the same - but I also see a band of &quot;want to be&quot;'s that take more time arguing with each other than addressing the problems at hand. These tipsters also focus on any easy question they can get there hands on (How do I format a date) - but rarely tackle any more difficult problem than that.

To these tipsters I say - &quot;Get a life or a job&quot; - they would then waste a lot less of everyone's time.

paulmarr

 
PaulMarr - I find both of your responses offending as well - and also note it was neither of your answers that even attempted to help the question at hand.

Yes you are correct we did not address the problem of the user....Why??? In my case, and I am quite sure in the case of SV and Naith, it was because an adequate answer was given by lbass as to how to the solve the problem...subsequently confirmed by the user that successfully adopted the suggestion.

What I and others did address was what (I feel anyway) was misinformation about the use of Shared versus Global variables given by yourself.

If a variable was truly global - then why can't other reports access it?

That is a truly laughable statement. CR Global variables have been around basically since the beginning of the report creation...they were never designed to communicate with subreports...CR created the Shared variable concept in version 7 to make the transfer of info easier, replacing functions that were awkward to use...nothing more...no extra functionality in the main report.

I also see a band of &quot;want to be&quot;'s that take more time arguing with each other

What..you are refering to myself, Synapsevampire, Naith, and others with this are you??? Well I won't comment other than say your view isn't shared by most in this forum as shown by the participant voting.


Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
This thread's taken a bit of an unexpected turn...

I apologise if you found my post offensive, Paul. It certainly wasn't intended to be.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top