//CreateDate Create_On added to source data only recently,
// so Due_on is used on older records.
If isnull({WORKORDER_CSV.CREATED_ON}) or {WORKORDER_CSV.CREATED_ON} = "" then
{WORKORDER_CSV.DUE_ON}
Else date({WORKORDER_CSV.CREATED_ON})
//BusDaysLastMonth
Local numbervar i := 0;
Local numbervar Total := 0;
//Number of Days in the previous Month:
Local numbervar MonthEnd := datepart("d",DateAdd("d",-1,Date(Year(CurrentDate),Month(CurrentDate),1))-1);
(If Month(CurrentDate) > 1 Then
For i := 1 to MonthEnd //to last day of last month
Do (if DayOfWeek(date(Year(CurrentDate), Month(CurrentDate)-1,i)) in 2 to 6
Then Total := Total + 1)
Else //If previous month is December
For i := 1 to MonthEnd //to last day of last month
Do (if DayOfWeek(date(Year(CurrentDate)-1,12,i)) in 2 to 6
Then Total := Total + 1));
Total;
The #MTD Running total is a count of records coming in, evaluated on the formula at the end of my previous message and resets on a change of the group. So if I replace the running total with a var = var+1 I can sort on a Formula value derived from it?