Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running total on multi-expression formula 1

Status
Not open for further replies.

bjornagin

Programmer
Dec 28, 2005
9
US
I'm having a bit of a problem with Crystal Reports 7.

I have a multi expression formula similar to the following:

@Formula1
=========
numberVar uvSchd :=0 ;

if({@uv01}>0) then uvSchd := {@uv01} ;
if({@uv02}>0) then uvSchd := uvSchd + {@uv02} ;

uvSchd*15/60

The formulas that get added in (uv01, uv02) consist of a running total minus a formula (which is an if-else that returns a number)

When I attempt to create a running total summarizing @Formula1 I get the error "You cannot select this field to summarize/reset/evaluate".

Is there a way to work around this?

Thanks

 
Use another variable to summarize the formula. Change your formula to:

whileprintingrecords;
numberVar uvSchd :=0 ;
numbervar sumuvschd;

if({@uv01}>0) then uvSchd := {@uv01};
if({@uv02}>0) then uvSchd := uvSchd + {@uv02};
sumuvschd := sumuvschd + uvSchd*15/60;
uvSchd*15/60

Then create a display formula for the report footer:
whileprintingrecords;
numbervar sumuvschd;

If you actually want to summarize at a group level, then add a reset formula to be placed in the group header:

whileprintingrecords;
numbervar sumuvschd := 0;

-LB
 
That worked! Thanks for your helpful speedy response.

Bjorn
 
Now that I've tinkered a bit more I have one other question based on the logic above. I am creating both a total both at the group footer and report footer. I did as you described above for the group footer and it works great. To also get a report total I modified the formula in the group footer to be:

whileprintingrecords;
numberVar sumuvSchd;
numberVar totSchd := totSchd + sumuvSchd;
sumuvSchd

and in the Report Footer I have:

whileprintingrecords;
numberVar totSchd;

The problem I'm seeing now is that the last group footer value seems to get added in twice when the value displays in the report footer.

Thanks again for your help.
 
Instead of modifying the group footer formula, you should modify the accumulation formula:

whileprintingrecords;
numberVar uvSchd :=0 ;
numbervar sumuvschd;

if({@uv01}>0) then uvSchd := {@uv01};
if({@uv02}>0) then uvSchd := uvSchd + {@uv02};
sumuvschd := sumuvschd + uvSchd*15/60;
totSchd := totSchd + uvSchd*15/60;
uvSchd*15/60

-LB


 
I could have swore that I tried the very same modification you suggested before my last post and it didn't work. This time it works. [blush]

Again, thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top