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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a formula to sumarize a column created by a formula 1

Status
Not open for further replies.

CrystalBlues

Technical User
Nov 11, 2010
4
US
I have a report where I created the following formula:

Sum ({Data.UnitsCharged}, {Data.ServiceCode}) * {Data.Proc_Time_Standard} / 60

My report indicates how long a procedure should take in minutes and also how many times a procedure was done. This formula takes the qty x minutes and divides by 60 to indicate how many hours per day the procedure took.

What I am having a problem with is trying to calcualate a total for this column created using the above formula.

Right click insert Sum is not an option for the data in this column. If using Excel, I can create a total for this column using the following: fx = SUM (H7:H62)

Is there a way to create a SUM for this column in Crystal or is this a limitation of Crystal Reports 9.0?
 
Use a variable. Create a formula like this:

//{@accum}:
whileprintingrecords;
numbervar sumhrs := sumhrs + Sum ({Data.UnitsCharged}, {Data.ServiceCode}) * {Data.Proc_Time_Standard} / 60

Place the above formula in the same section in which you are displaying the formula you want to sum and then suppress it.

In the report footer, use a formula to show the result:
//{@display}:
whileprintingrecords;
numbervar sumhrs;

If you want the result at a group footer level, move the display formula to the group footer and add a reset formula in the group header:

//{@reset}:
whileprintingrecords;
numbervar sumhrs;
if not inrepeatedgroupheader then
sumhrs := 0;

-LB
 
Thanks for the response, however, I was unable to get this to post the total results.
 
Well, it should have worked, so you need to explain exactly how you implemented it and then explain the results you got and in what way they were incorrect.

-LB
 
I copied the formula and placed it in the same section as my formula and suppressed the section.

//{@accum}:whileprintingrecords;numbervar sumhrs := sumhrs + Sum ({Data.UnitsCharged}, {Data.ServiceCode}) * {Data.Proc_Time_Standard} / 60

I also placed the following formula in the report footer.

//{@display}:whileprintingrecords;numbervar sumhrs;

Results just would not display. Empty box
 
What box?

I wonder if you added the returns back after copying, as right now the display formula is entirely commented out. In formula one, remove: "//{@accum}:" and in formula two remove "//{@display}:". These are just the names of the formula and are okay to put in the formula if commented out, but you can't allow other items on the same line, as they too would be commented out and then would not execute.

Just a guess here at what you might have done.

-LB
 
LBass - You are the Man!!

I redid my original formula to:

whileprintingrecords;numbervar sumhrs := sumhrs + Sum ({Data.UnitsCharged}, {Data.ServiceCode}) * {Data.Proc_Time_Standard} / 60

And added this to the report footer

whileprintingrecords;numbervar sumhrs;

And got the total I was looking for!!

The empty box was the box I displayed which should have had the total... which it does now!!

Thanks for all your assistance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top