Crystal Reports - Maximum of Field with Shared Variable

Hello:

I have a report that has one shared variable.  I'm using that amount in a calculation.  I need to get the Maximum, Minimum and Average amounts into a Group Footer.  When I attempt to use the Maximum (or the other functions) I get "This field cannot be summarize" - What is the best way to accomplish this?

Thank you!

Here is the formula that I'm using that I need to summarize the End Result.  UseReal is the Shared Variable.
//@DailyUsage
if {PD9_LAST_100_DELIVERIES.DeliveryNumber}="00" then Shared Numbervar UseReal else  

IF {@DetailInterval}<>0 then {PD9_LAST_100_DELIVERIES.Quantity}/{@DetailInterval} else 0

I tried Creating 3 formulas to get the information - a Reset for the Header, Running Total formula on the line and Total for the Result.  I'm obviously doing something wrong, it will not let me use Maximum on my Formula.
Erin LealeConsultant/ControllerAsked:
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:
Summaries are done in the second pass through the report before shared variables are evaluated so the value is not known.

Do you have a subreport that sets the value for the shared variable?
If not then there is no need to use shared variables.

You could try

//@DailyUsage
 if {PD9_LAST_100_DELIVERIES.DeliveryNumber}="00" then 
     Numbervar UseReal 
else  IF {@DetailInterval}<>0 then 
     {PD9_LAST_100_DELIVERIES.Quantity}/{@DetailInterval} 
else 
     0

Open in new window


What is the @DetailInterval formula?

How is UseReal given a value?

mlmcc
Erin LealeConsultant/ControllerAuthor Commented:
I am using a subreport, the UseReal is coming from the subreport and that number is used in the DailyUsage formula if the delivery sequence is 00.  

The @DetailInterval is this formula:
{PD9_LAST_100_DELIVERIES.DeliveryDate}-{PD9_LAST_100_DELIVERIES.PreviousDeliveryDate}

Everything works until I add the UseReal to the mix - then nothing can summarize.  

Thanks.
mlmccCommented:
IN that case you will have to use another method

Try this

IN the report header add a formula
WhilePrintingRecords;
Global NumberVar CurrentMax;
Shared NumberVar UseReal;
''

Open in new window


In the Group Header add a formula
WhilePrintingRecords;
Global NumberVar CurrentMax;
Shared NumberVar UseReal;
CurrentMax := -99999999
''

Open in new window


Depending on where the subreport is.  My guess is it is in the detail section.  If it isn't then add another section where the subreport is.
Add another detail section
Right click the section in the left margin
Click INSERT SECTION BELOW

Add a formula to the new section
WhilePrintingRecords;
Global NumberVar CurrentMax;
Shared NumberVar UseReal;
Local NumberVar NewValue;

 if {PD9_LAST_100_DELIVERIES.DeliveryNumber}="00" then 
     NewValue := UseReal 
else  IF {@DetailInterval}<>0 then 
     NewValue := {PD9_LAST_100_DELIVERIES.Quantity}/{@DetailInterval} 
else 
     NewValue := 0;
If NewValue > CurrentMax then
    CurrentMax := NewValue;
''

Open in new window


In the group footer add a formula
WhilePrintingRecords;
Global NumberVar CurrentMax;
Shared NumberVar UseReal;
CurrentMax 

Open in new window


mlmcc

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
Erin LealeConsultant/ControllerAuthor Commented:
Thank you!   This worked perfectly!
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.