Bennie47250
Programmer
Using Crystal Version 7.0
I have a formula that is determining the number of business days it takes to close a service ticket. Now I would like to get the average number of days for each group.
When I right click on the field, I don’t have the option to insert a subtotal, grand total or a summary.
I then thought will I just create a running total and then do the math. I receive the error message that “You can’t select this field as the field to summarize/reset/evaluate.
The formula I’m using to determine the number of business days is:
//CALCULATE THE NUMBER OF BUSINESS DAYS
//INCLUDING HOLIDAYS IN THE TOTAL
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//INPUT REQUIRED _ INPUT REQUIRED _ INPUT REQUIRED
//ENTER FIRST DATE
DateVar FirstDay:= {@MinBeginASPendAsDate}; //enter your start / first date here
//ENTER END DATE
DateVar LastDay:= {@MaxEndASCompAsDate}; //enter your end / last date here
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//END INPUT REQUIRED _ END INPUT REQUIRED _ END INPUT
//Other variables used in the formula //DECLARES VARIABLES
Numbervar Days;
Numbervar Weekends;
Numbervar Finaldays;
DateVar StartDate;
DateVar EndDate;
//BEGIN FORMULA:
//*********************************************************
//FINISH FORMULA IF FIRSTDAY OR LASTDAY IS NULL
//********************************************************* //ERROR CHECKING
IF FirstDay <=Date(0,0,0) or LastDay <=Date(0,0,0) then
Finaldays:= 0
//ELSE ASSIGN FINALDAYS
//*********************************************************
ELSE
(
//ASSIGN START DATE
//*********************************************************
//if the first day falls on a weekend, StartDate is equal
//the following Monday for calculation reasons
If DayOfWeek(FirstDay) = 7 Then //IF START DATE IS SATURDAY (7) THEN ADD 2 DAYS TO GET TO MONDAY
StartDate := FirstDay + 2
Else If DayOfWeek(FirstDay) = 1 Then //IF START DATE IS SUNDAY (1) THEN ADD 1 DAYS TO GET TO MONDAY
StartDate := FirstDay + 1
Else
StartDate:=FirstDay; //IF START DATE IS NOT SAT OR SUNDAY THEN USE START DATE
//ASSIGN END DATE
//*********************************************************
//if the last day falls on a weekend, EndDate is equal to
//the following Monday for calculation reasons
If DayOfWeek(LastDay) = 7 Then //IF END DATE IS SATURDAY (1) THEN SUBTRACT 1 DAYS TO GET TO FRIDAY
EndDate := LastDay - 1
Else If DayOfWeek(LastDay) = 1 Then //IF END DATE IS SUNDAY (1) THEN SUBTRACT 2 DAYS TO GET TO FRIDAY
EndDate := LastDay - 2
Else
EndDate := LastDay; //IF END DATE IS NOT SAT OR SUNDAY THEN USE END DATE
//CALCULATE DAYS (including today, First Day and Last Day)
//*********************************************************
Days:= (EndDate - StartDate) ; + 1
//CALCULATE WEEKENDS
//*********************************************************
Weekends:= (EndDate - (dayofweek(EndDate)-1)) - (StartDate
+ (7-dayofweek(StartDate))) +1;
if Weekends = 2 then
Weekends:=Weekends
else if Weekends <=0 then
Weekends:=0
else
Weekends:= (((Weekends-2)/7)*2) + 2;
//CALCULATE FINAL DAYS (DAYS - WEEKENDS)
//*********************************************************
FinalDays:=Days-Weekends;
if FinalDays < 0 then
FinalDays:=0;
);
//DISPLAY NUMBER OF BUSINESS DAYS IN THE RANGE
//*********************************************************
FinalDays;
I have a formula that is determining the number of business days it takes to close a service ticket. Now I would like to get the average number of days for each group.
When I right click on the field, I don’t have the option to insert a subtotal, grand total or a summary.
I then thought will I just create a running total and then do the math. I receive the error message that “You can’t select this field as the field to summarize/reset/evaluate.
The formula I’m using to determine the number of business days is:
//CALCULATE THE NUMBER OF BUSINESS DAYS
//INCLUDING HOLIDAYS IN THE TOTAL
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//INPUT REQUIRED _ INPUT REQUIRED _ INPUT REQUIRED
//ENTER FIRST DATE
DateVar FirstDay:= {@MinBeginASPendAsDate}; //enter your start / first date here
//ENTER END DATE
DateVar LastDay:= {@MaxEndASCompAsDate}; //enter your end / last date here
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//END INPUT REQUIRED _ END INPUT REQUIRED _ END INPUT
//Other variables used in the formula //DECLARES VARIABLES
Numbervar Days;
Numbervar Weekends;
Numbervar Finaldays;
DateVar StartDate;
DateVar EndDate;
//BEGIN FORMULA:
//*********************************************************
//FINISH FORMULA IF FIRSTDAY OR LASTDAY IS NULL
//********************************************************* //ERROR CHECKING
IF FirstDay <=Date(0,0,0) or LastDay <=Date(0,0,0) then
Finaldays:= 0
//ELSE ASSIGN FINALDAYS
//*********************************************************
ELSE
(
//ASSIGN START DATE
//*********************************************************
//if the first day falls on a weekend, StartDate is equal
//the following Monday for calculation reasons
If DayOfWeek(FirstDay) = 7 Then //IF START DATE IS SATURDAY (7) THEN ADD 2 DAYS TO GET TO MONDAY
StartDate := FirstDay + 2
Else If DayOfWeek(FirstDay) = 1 Then //IF START DATE IS SUNDAY (1) THEN ADD 1 DAYS TO GET TO MONDAY
StartDate := FirstDay + 1
Else
StartDate:=FirstDay; //IF START DATE IS NOT SAT OR SUNDAY THEN USE START DATE
//ASSIGN END DATE
//*********************************************************
//if the last day falls on a weekend, EndDate is equal to
//the following Monday for calculation reasons
If DayOfWeek(LastDay) = 7 Then //IF END DATE IS SATURDAY (1) THEN SUBTRACT 1 DAYS TO GET TO FRIDAY
EndDate := LastDay - 1
Else If DayOfWeek(LastDay) = 1 Then //IF END DATE IS SUNDAY (1) THEN SUBTRACT 2 DAYS TO GET TO FRIDAY
EndDate := LastDay - 2
Else
EndDate := LastDay; //IF END DATE IS NOT SAT OR SUNDAY THEN USE END DATE
//CALCULATE DAYS (including today, First Day and Last Day)
//*********************************************************
Days:= (EndDate - StartDate) ; + 1
//CALCULATE WEEKENDS
//*********************************************************
Weekends:= (EndDate - (dayofweek(EndDate)-1)) - (StartDate
+ (7-dayofweek(StartDate))) +1;
if Weekends = 2 then
Weekends:=Weekends
else if Weekends <=0 then
Weekends:=0
else
Weekends:= (((Weekends-2)/7)*2) + 2;
//CALCULATE FINAL DAYS (DAYS - WEEKENDS)
//*********************************************************
FinalDays:=Days-Weekends;
if FinalDays < 0 then
FinalDays:=0;
);
//DISPLAY NUMBER OF BUSINESS DAYS IN THE RANGE
//*********************************************************
FinalDays;