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

Summaries in Main Report - While Sub report is placed in Details 1

Status
Not open for further replies.

KeerthanaCR

Technical User
Sep 3, 2008
7
US
I have a Main Report,In the details i have 4 sub reports, placed in details.

I created a shared variable in each of the sub report and used in group footer in the main section ( each group has only one record and it works more like representing details. As I could not use the shared variable in details section of main, I created this group).

Now I have to summarize the main report,But I am not able to summarize the fields that were from Subreport.

Is there a way to calculate summaries.

Thank you in advance
Keerthana
 
You have not indicated what kind of summary you want to do. You can add shared variables for a report total by adding the following to the group footer:

whileprintingrecords;
shared numbervar amt;
numbervar totamt := totamt + amt;

Then in the report footer, use:

whileprintingrecords;
numbervar totamt;

-LB
 
The problem looks to me more complicated to me atleast. Let me explain in detail what i have in my main report and the subreports variables i have used in the main report.

In the main report,
I have study\trial information stored in one database ( study id)
I have two different locations, which stored patients information on which study\trial is performed( different databases)

We need to know the maximum number of patients enrolled first for each study. So I created two subreports to get the number of patients for each study.. ( query has prompt on study and is linked to main report on study_id). A shared variable is created in each subreport that gets number of patients and placed in details.

In the main report, sub reports are placed in details section. To make use of the shared variables in the main report, I created two shared variables in main report as well -One of each subreport and placed in Group footer. ( Group is created on study and all details is placed in study. each study has only one row and placing this in group footer works more like displaying details.)

To get the maximum number of patients. I compared the two shared variables from two subreports and displayed the maximum one in the group footer.

Now, I need to create a cross tab or summary information to display Number of patients in different ranges ( like between 10 and 100 , between 100 and 1000 etc).

I created a formula to display different ranges based on the max number of patients enrolled formula.
( like if the value is between 10 and 100 display 'Between 10 and 100)

When I place this formula in the cross tab, It is not calculated correctly. and so the number of studies? So I am wondering how can i make this work!

Thank you in advance.
Keerthana

Hope the post is not too confusing?
 
I don't think it is possible to use shared variables in a crosstab, since an inserted crosstab would process in an earlier pass. I'm having a little trouble visualizing the data. Does it look like this?

Loc A Loc B Max
Study 1 50 100 100
Study 2 10 5 10
Study 3 30 35 35

...and then you want to take the max column and determine how many the total number of patients that fall into certain ranges? In the above case, if the ranges were as follows, the results would be:

0 - 9 0
10 - 40 45
41 - 1000 100

Is this what you want to do?

-LB
 
Hello LB,

Thank you for your time. You are almost right in the sample data except the end result -summary. In the summary i need to calculate number of studies with in the range.

Loc A Loc B Max
Study 1 50 100 100
Study 2 10 5 10
Study 3 30 35 35

In the above sample data,
for study1, 50 and 100 will be displayed in Details
in Group footer
I will have
Study Number of Patients
Study 1 100

and My details section in minimized, not supressed or hidden.
and the data looks like

Study Number of Patients
Study 1 100
Study 2 10
Study 3 35

Now I need to somehow display the data as below. Calculate number of studies in the patients range.

Range Number of Studies
0-9 1
10-100 2

Hope this ic clear.

If not with cross-tab, is there any other way we can achieve the same in crystal reports?

Thank you again for your time on this query
Keerthana

 
Let's say you calculate your maximum like this:

whileprintingrecords;
shared numbervar locA;
shared numbervar locB;
numbervar maxloc := maximum([locA,locB]);

Continue the same formula (which is placed in the study group footer) by tacking on the following at the end:

numbervar range0to9;
numbervar range10to100; //etc.
if maxloc in 0 to 9 then
range0to9 := range0to9 + 1;
if maxloc in 10to100 then
range10to100 := range10to100 + 1; //etc.

Then in the report footer, use a separate display formula for each range, along with a text box identifying the range:

//{@displayrange0to9}:
whileprintingrecords;
numbervar range0to9;

-LB
 
Thank you lb, I followed the formula as you described.

I need to have the formuala for each department. Ithink i can follow the same apporach and get the counts.

I did create few formulas and looks like they are working fine.

However, I guess i can't hide details as my sub reports are placed in details. When i hide the details, all the counts in my report are Zero.

Is there any other away to get around this issue. I just want to display the summary information not the details.

Thank you
keerthana
 
You should have mentioned the departments in your initial post. If department is the outer group, then all you need to do is add a reset formula in the department group header:

whileprintingrecords;
numbervar maxloc;
numbervar range0to9;
numbervar range10to100;
if not inrepeatedgroupheader then (
maxloc := 0;
range0to9 := 0;
range10to100 := 0
);

To have the detail section disappear, do the following. First do NOT suppress the detail section or the subreports themselves. Instead, go into each subreport and suppress all sections within the subreport. In the main report, remove the borders on each subreport and right click on each sub->format subreport->subreport tab->check "suppress blank subreport". Then still in the main report go into the section expert->details->check "suppress blank section." The detail section will disappear once you have done this to all subreports, but the shared variables will still pass.

-LB
 
Hi LB,

Thank you for your reply. Hiding of details has really helped to make the report looks good. The report is working fine, after implementing the formulas as you mentioned. The only change, I have made is added another reset formula at study header, as the maxloc is not displaying the correct value. I guess shared variable is getting carried away for the next record.

Let us
for study1 i have
study loc1 loc2 max
study1 20 30 30
study2 10 5 20 As the value 20 is carried away to the second study.

So I created a variable to reset the loc1 and loc2 values.

whileprintingrecords;
shared numbervar loc1;
shared numbervar loc2;

if not inrepeatedgroupheader then (
loc1 := 0;
loc2 := 0;
);

and placed this in group header of Study.

So It is working fine.

Now we have a new reuqest from users, to count number of Areas based on ranges( range0to9 and range10to100).
( An area will have multiple studies.)
As an Area will have multiple studies, I need to sumup the number of patients to Area level (summing up maxloc to Area).

As I am reseting the maxloc at the group level study, I am not able to sumup the maxloc to Area level.

The formula, i have written to calculate sum of maxloc is

whileprintingrecords;
numbervar totalmaxloc :=0;
totalmaxloc := totalmaxloc + maxloc;

as maxloc is reset on study level, when i place this variable in group footer of the AREA, I am getting only maxloc for the last study in an AREA.

Hope my problem defintion is clear.

How can i calculate this maxloc; sum correctly at the group level AREA.

Thank you for your time
Keerthana
 
I'm confused about your group structure--please idnetify your groups again. By "area" do you mean "department"?

I also cannot tell what the final output would look like. Do you mean you want results per range for the area as a whole?

-LB
 
Hi LB,

The group structure is department >>AREA >> STUDY.

Initially, we calculated number of studies that falls in a specific range like "0 to 9, "10 to 100" ( max of the value from loc1 and loc2 subreports). For each study we get the maxloc from the subreports loc1 and loc2 ( subreport is linked on study number prompt?)

Now, we want to count, number of Areas that falls in a specific range like "0 to 9" , "10 to 100" etc.
To get the range, First i need to sum up the maxloc to AREA.

I am not able to get this sum right as i am resetting the shared variables loc1, loc2 in study group header.
I am always getting the sum for AREA is same as the maxloc for the last record in the study.

Hope this makes clear.

Thank you
Keerthana
 
Resetting of the loc1 and loc2 variables should not affect your calculation--your totalmaxloc formula is wrong, as you are resetting it by setting it to zero when in fact it needs to accumulate across records. Create these formulas:

//{@resettotmaxloc} to be placed in GH#2 (Area):
whileprintingrecords;
numbervar totmaxloc;
if not inrepeatedgroupheader then
totmaxloc := 0;

//{@accummaxloc} to be placed in GF#3_b and suppressed:
whileprintingrecords;
numbervar totmaxloc := totmaxloc + maxloc;

//{@accumarearanges to be placed in GF#2 (area):
whileprintingrecords;
numbervar totmaxloc;
numbervar arearange0to9;
numbervar arearange10to100; //etc.
if totmaxloc in 0 to 9 then
arearange0to9 := arearange0to9 + 1;
if totmaxloc in 10 to 100 then
arearange10to100 := arearange10to100 + 1; //etc.

//{@displarearanges} to be placed in the department group footer (one for each range):
whileprintingrecords;
numbervar arearange0to9;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top