We help IT Professionals succeed at work.

Analyze Shared Variable?

Nicole McDaniels
on
169 Views
Last Modified: 2017-04-03
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

Mike McCrackenSenior Consultant
CERTIFIED EXPERT
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
CERTIFIED EXPERT
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

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
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

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
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
Just copied and pasted.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions