Analyze Shared Variable?

Nicole McDaniels
Nicole McDaniels used Ask the Experts™
on
I have a subreport that is passing a number to the main report for each sample. (In the red box below)

Now I want to create 2 formulas in my main report  in my footer to do:
1. Tells me the number of samples with a value >10
2. A percentage of samples with less than 10.

How do I do this and is it possible to evaluate shared variable values?

Subreport formula:
WhilePrintingRecords;
Shared numbervar Turnaround:={@TurnaroundTime}

Main report formula:
Shared numbervar Turnaround;
Turnaround

2017-03-31_8-55-24.jpg
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Where are the formulas?

Change the sub report formula to gather the information
Add a formula to the main report to declare the shared variables
Name - DeclareVariables
Location - main report header
WhilePrintingRecords; 
Shared numbervar Turnaround;
Shared NumberVar NumGT10;
Shared NumberVar NumLT10;
Shared NumberVar TotalSamples;
''

Open in new window


Change the subreport formula
WhilePrintingRecords; 
Shared numbervar Turnaround;
Shared NumberVar NumGT10;
Shared NumberVar NumLT10;
Shared NumberVar TotalSamples;

Turnaround := {@TurnaroundTime};
TotalSamples := TotalSamples + 1;
If Turnaround > 10 then
     NumGT10 := NumGT10 + 1;
Else
    NumLT10 := NumLT10 + 1;
Turnaround 

Open in new window


In the report footer add 2 formulas
Name - NumGT10
WhilePrintingRecords; 
Shared NumberVar NumGT10;
NumGT10

Open in new window


Name - Less10Percent
WhilePrintingRecords; 
Shared NumberVar NumLT10;
Shared NumberVar TotalSamples;

NumLT10 / TotalSamples * 100

Open in new window


mlmcc

Author

Commented:
My shared variable formula in the main report is in the group footer..(which displays the Approved Date from the subreport)

I tried to create the subreport formula listed above but got an error stating with "else" the remaining text isn't part of the formula
Else
NumLT10 := NumLT10 + 1;
Turnaround
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Remove the semicolon before the ELSE

If Turnaround > 10 then
     NumGT10 := NumGT10 + 1
Else
    NumLT10 := NumLT10 + 1;

Open in new window


mlmcc
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Author

Commented:
Unfortunately, I have my subreport passing the date to the main report. There are several dates for each row so the formulas above won't work. My subreport is passing the date to the main report. Then I have a formula using that date, plus a date in the main report to give me a number.
The turnaround time number (in the red box above) is the difference between the date collected and the approval date where the approval date is the subreport shared variable. I also have a reset subreport in my main report for this approval date.

Group Footer Main report:
@approveddate
Shared datetimevar Approveddate;
ApprovedDate

@cycledays
DateDiff("d",{@DateCollected},{@ApprovedDate})

I then have 1  subreports in my group header which gives my ApproveDate
and a reset formula in the group header
shared datetimevar Approveddate:=date(0, 0, 0);


Reset:
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
I wasn't sure where the calculation was.

Try this
Name - DeclareVariables
Location - main report header
WhilePrintingRecords; 
Global NumberVar NumGT10;
Global NumberVar NumLT10;
Global NumberVar TotalSamples;
''

Open in new window


CycleDays
WhilePrintingRecords; 
Local numbervar Turnaround;
Global NumberVar NumGT10;
Global NumberVar NumLT10;
Global NumberVar TotalSamples;

Turnaround := DateDiff("d",{@DateCollected},{@ApprovedDate});
TotalSamples := TotalSamples + 1;
If Turnaround > 10 then
     NumGT10 := NumGT10 + 1;
Else
    NumLT10 := NumLT10 + 1;
Turnaround 

Open in new window


Name - NumGT10
WhilePrintingRecords; 
Global NumberVar NumGT10;
NumGT10

Open in new window


Name - Less10Percent
WhilePrintingRecords; 
Global NumberVar NumLT10;
Global NumberVar TotalSamples;

NumLT10 / TotalSamples * 100

Open in new window


mlmcc

Author

Commented:
The extra semicolon needs to be deleted, but it worked. Thanks so much!

If Turnaround > 10 then
     NumGT10 := NumGT10 + 1
Else
    NumLT10 := NumLT10 + 1;
Turnaround
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Just copied and pasted.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial