Analyze Shared Variable?

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
Nicole McDanielsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
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
0
Nicole McDanielsAuthor 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
0
mlmccCommented:
Remove the semicolon before the ELSE

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

Open in new window


mlmcc
0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Nicole McDanielsAuthor 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:
0
mlmccCommented:
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nicole McDanielsAuthor 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
0
mlmccCommented:
Just copied and pasted.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.