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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppressing Records Based on Subreport Calc.

Status
Not open for further replies.

arachnoid

Programmer
Jun 14, 2002
108
US
I am attempting to suppress records if they are equal to zero based on a formula using a shared variable between the main report and a subreport in the Section Expert.

However, when I reference the formula in the section expert, it not only does no suppress records equal to zero, it also changes the value of the formula on the main report.

Can anyone suggest a formula for suppressing my unwanted records?

Any input would be greatly appreciated.

Regards,

 
First, where is the subreport located in the main report? What main report section are you trying to suppress? What is the shared formula in the subreport, and how are you referencing it in the section expert?

-LB
 
First, thanks for your response!

The subreport is located in the Group #1a Footer.

I am attempting to suppress Group Footer #1a and Group Footer #1b where the total in Group Footer #1b is = 0

The Shared Variable in the report is the total amount in the Subreport. I am calling the shared variable in Group Footer #1b and subtracting from the total in the main report, which is located in Group Footer #1a.

I am trying to suppress the records where the difference between the total in the main report - the total in the subreport = 0.

Hope that helps...

Thanks again!
 
You won't be able to suppress GF_a with the formula, only GF_b--unless you move the subreport to a group header section, in which case both GF_a and GF_b can be suppressed. You can suppress all sections within the subreport so that it does not appear. When referencing shared variable, only reference its name in the {@diff} formula, as in:

//{@diff}:
whileprintingrecords;
shared numbervar subamt;
sum({mainreport.amt},{table.groupfield}) - subamt;

Then use:

{@diff} = 0

for suppression.

-LB
 
I am trying to do something very similar, using CR8.0, to what arachnoid was doing. My main report summarizes dental claims for all groups in a given month by group type (HIPPA, Large Group, & SEHI). For each group, the report must show the total number of group employees that are eligible for dental benefits - this is the subreport. I am attempting to suppress group summary lines where the group has no (zero) eligible employees, by using a shared variable to pass the number back to the main report from the subreport. Unfortunately, every summary line (group) in the main report has the shared variable value of the previous group, therefore, the wrong group gets suppressed.
The main report displays only the summary line at Group Footer #2 (GroupID) since the data is exported to Excel for further manipulation (this is where the subreport is located and the shared value is reset). Group #1 (GroupType) is not displayed, but used to insure that all the groups of a particular type, remain together.
The subreport receives the GroupID and the RptMonth from the main report as parameters and displays the distinct count of all eligible employees for that group, in that month. The employee count is displayed in the Report Footer, although it is the same as the total from GF#1 (GroupID). GF#1 is where the shared value is set from the distinct count.
Can you tell me why my shared value is being passed to the wrong group? What am I not understanding correctly about shared variables?

Thank you for your help,

        Jamie Morrison
        Health Plan Data Analyst
(Report Developer)
        Clear Choice Health Plans
 
If your subreport is in GF#2a, then the shared variable will only be correct in GF#2b or in a section below that and before the subreport fires again. You also need to add a reset formula in the main report that should be placed in GH#2:

whileprintingrecords;
shared numbervar yourvar := 0;

-LB
 
lbass,

Thank you for your reply. I have already tried your suggestions. If I put the shared variable in any section below GF#2a (where the subreport is), it always has a zero value. And the only way I've been able to get the reset formula to work, is to place it in the same section (GF#2a) as the shared variable formula. Apparently, I'm doing something else wrong. Or, since this is the first time I've used shared variables in a report, I can't rule out the possibility that I have multiple errors causing this issue.

Again, thank you for your help,

        Jamie Morrison
        Health Plan Data Analyst
(Report Developer)
        Clear Choice Health Plans
 
You should be setting up the shared variable in the subreport, something like:

whileprintingrecords;
shared numbervar yourvar := distinctcount({table.employee});

You must place this on the subreport itself. If the sub is in GF#2a, you should then reference this formula in GF#2b. The reset formula MUST be placed in an earlier section, NOT the same section, which was why I suggested GH#2. Also make sure you are using "shared" and the same variable name in each formula. For further help, please show the contents of each formula and identify its location.

-LB
 
lbass,

[tab]I don't know what changed between the last time I did this and this time, but it's working now. At least as far as the shared variable being with the correct group. However, now I can't suppress GF#2a and GF#2b when the shared variable is 0 (zero). I set section GF#2a to Underlay following sections so that I could eliminate the extra lines produced by GF#2b. Here's how everything else is set up:
[tab][tab]
[tab][tab]//@SharedCnt -- in subreport RF
[tab][tab]WhilePrintingRecords;
[tab][tab]Shared numberVar SubsCnt := DistinctCount({membcovr.membno})

[tab][tab]//@SharedSubsCnt -- in main report GF#2b
[tab][tab]WhilePrintingRecords;
[tab][tab]Shared numberVar SubsCnt

[tab][tab]//@SharedReset -- in main report GH#2
[tab][tab]WhilePrintingRecords;
[tab][tab]Shared numberVar SubsCnt := 0

[tab]I've tried using the following in the Suppression formula area of both GF#2a and GF#2b:

[tab][tab]WhilePrintingRecords;
[tab][tab]Shared numberVar SubsCnt;
[tab][tab]SubsCnt = 0

and

[tab][tab]{@SharedSubsCnt} = 0

[tab]In every case, it suppresses everything, even when the value is not 0. Is there another way to do this?

[tab]Thanks,



        Jamie Morrison
        Health Plan Data Analyst
(Report Developer)
        Clear Choice Health Plans
 

[tab]Since there doesn't seem to be any way to suppress both group footers, only when the shared variable is zero, I have decided to approach this report from a completely different standpoint. It makes the main reports record selection a little more complex, but my documentation should clarify what's happening for those who may have to modify my work.

[tab]Thanks again for all your help. I at least have a much better picture of how to implement a shared variable in future projects.

        Jamie Morrison
        Health Plan Data Analyst
(Report Developer)
        Clear Choice Health Plans
 
Sorry I didn't get back to you. Lost track of this thread. You can only use shared variables to suppress sections that are below the one containing the subreport.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top