Avatar of Nicole McDaniels
Nicole McDaniels
 asked on

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
Crystal Reports

Avatar of undefined
Last Comment
Mike McCracken

8/22/2022 - Mon
Mike McCracken

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
Nicole McDaniels

ASKER
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 McCracken

Remove the semicolon before the ELSE

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

Open in new window


mlmcc
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Nicole McDaniels

ASKER
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:
ASKER CERTIFIED SOLUTION
Mike McCracken

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Nicole McDaniels

ASKER
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 McCracken

Just copied and pasted.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.