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

Group totals as parameters for subreports 2

Status
Not open for further replies.

Andyherm

Technical User
Nov 29, 2006
25
GB
Hi,
I'm writing a report which uses several subreports, a few of them based on a number of sites grouped together in areas which have downtime records linked to them.
I've got the main report setup to group first by area, then by site and in the area group header I've got a distinctcount of the number of sites in each area.
How can I use these individual subtotals as parameters for the subreports?
Many thanks,
Andy.
 
I think you should explain more specifically what you are trying to do. If you want to match the groups in the main report with corresponding groups in the subreports, then you would create the same grouping formula in the subreports that you use in the main report to cluster the sites, and then link the two formulas to each other in the subreport linking expert.

-LB
 
Appologies for the late response.
I'm trying to get individual counts of the total number of site records in four seperate geographical areas in the main report and then use them for calculations in subreports for example, the subreport I'm most concerned with shows only the sites which have downtime records associated to them but I'd like to be able to compare these downtime records to the total number of sites in their respective areas to calculate network availability by area.
I'm looking to be able to create these four individual counts by area and then pass them seperately to the subreport but I'm only able to pass the grand total.
 
So where are the subreports located that you want to pass the values to? The report footer?

-LB
 
No I'm currently using a report header section for each subreport.
Until now all my subreports had been unlinked, this is the first sr I've needed to link to the main report.
 
Hi,
If the sub is in the Report Header is will be very awkward to link it to the Main report, since it will try to run before the main report ( the RH runs before any Groups or Detail sections)..Not a great place to put it..

Is there some reason for that placement?





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Ah, no there's no reason other than I wanted to have each subreport on a page of it's own and that seemed like the best way to accomplish it at the time.
As you've undoubtedly guessed I'm pretty new to cr :)
Would the best way to seperate these be by using the report footer(s) then?
Thanks both of you for help and patience!
 
You can't pass data upwards from the main report to the sub, since you have to use shared variables, which occur whileprintingrecords. Why are you linking the sub? You wouldn't actually set the values up as a parameter, although you could link on other parameters, e.g., if you wanted to define the same time period in both main and sub.

You should either move the subreports to the report footer, or insert another report header section_a to hold a subreport that calculates the group values for the entire areas. Let's say you choose to do the latter. In the new sub in RH_a, create a formula like the following and place it in the area group header:

whileprintingrecords;
shared numbervar array dcntsite;
shared stringvar array area;
numbervar cnt := cnt + 1;

if cnt < 1000 then (
redim preserve dcntsite[cnt];
dcntsite[cnt] := distinctcount({table.site},{table.area});
redim preserve area[cnt];
area[cnt] := {table.area}
);

Then in the subreport in RH_b, create a formula:

whileprintingrecords;
shared numbervar array dcntsite;
shared stringvar array area;
numbervar tot;
numbervar i;

for i := 1 to ubound(dcntsite) do (
if area = {table.area} then
tot := dcntsite
);
tot

You can do a calculation right in this formula or you can reference tot in another formula, e.g.:

whileprintingrecords;
numbervar tot;
distinctcount({table.site},{table.area})%tot

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top