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

Cannot calculate Sub-Total

Status
Not open for further replies.

1994mkiv

Technical User
May 24, 2007
28
US
Posting the pic for better answer.
over_time.gif



As you can see the report is grouped by week then Dept then Employee ID. The second column is subtotal of the employee hours for the whole week. I used the function for the third column to calculate the over time which is

If sum({employee.payhour}, “weekly”)>40 then (sum({employee.payhour}, “weekly”)-40)
Else sum({employee.payhour}, “weekly”)

Now I need to do the subtotal by dept. calculating the employee.payhour was easy and used the built-in subtotal function. The overtime is not even an option there. So first thing I did was write another function sum(@overtime, “employee.dept”) it gave me a error stating the running total cannot be calculated. When I looked at the option for running total @overtime is not even listed there either. Can somebody tell me how can I get the subtotal of overtime by dept.
 
This is the classic 3 formula approach using variables.

First initialize the variable in the date group header:
Code:
WhilePrintingRecords;
If Not InRepeatedGroupHeader then Numbervar OTSub:=0;

In the employeeID group footer, you accumulate the OT:
Code:
WhilePrintingRecords;
Numbervar OTSub:=OTSub+{@overtime};

In the employeeID group footer, you display it:
Code:
WhilePrintingRecords;
Numbervar OTSub;



Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
Your overtime formula is missing the group condition, and should default to 0 I think:

If sum({employee.payhour}, {employee.date},“weekly”)>40 then
sum({employee.payhour},{employee.date}, “weekly”)-40 else
0
...although maybe you just posted the formula incorrectly.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top