173.33 hours per complete month [events]
Because we are using events, it is usually much simpler to create "Made Up" values (e.g., in the transformation expression). We could attempt it in a data default expression using #MPGEN (e.g., 12 #MPGEN (#NEXTBEGMTH StartEventDates, #ENDMTH StopEventDates, but it's very complicated to do that in a data default because there are no calculation dates in a data default expression! (Of course, that's why it's sometimes easier to do things in a data default than in a transformation expression, but not this case).
Please review the example 1,000 hours = 1 year (assume 173.33 hours per complete month) [no events, just hire and decrement] and look carefully at this line Start_dt:= #NEXTBEGMTH DateOfHire & in the hours transformation expression. If we replaced the scalar data dictionary field DateOfHire with an array containing the start events dates (e.g., Start_dt:= #NEXTBEGMTH StartEventDates), the expression may seem to work (unless you test it with all those event combinations recommended above). But, when you have more than once event in a month, you'll find the expression grants hours when it shouldn't. It's very complicated (and very easy to make a mistake) to make that expression work properly, so that's why we're going to count the number of days you worked in a month instead, it makes for a much simpler transformation expression.
Preliminaries:
First we need to create two new effective dated arrays to hold the start and stop event dates (e.g., StartEventDates and StopEventDates)
Create a new Service Definition:
Working:= (#DATE >= StartEventDates) #AND (#DATE <= StopEventDates) &
; a 1 indicates you were working on that calculation date; a 0 indicates you are NOT working on that calculation date
; because all the start and stop event dates (AND the day before), we know that
NetDaysInMth:= (12 #MPNET #DATE) #MIN (#DAY #DATE) &
; (1) #MPNET gives us, for each date in the month, the current date - previous date, or net days
; (2) There is no previous date for the first date in each month (as far as 12 #MPNET is concerned)
; so the first result of 12 #MPNET, in every month, is a date! That's because there is no
; previous date for the first date in each month (as far as 12 #MPNET is concerned).
; Limiting the result of #MPNET it to #DAY #DATE gives us the proper net days.
NetWorkingDaysInMth:= NetDaysInMth * Working &
; ignore the days not worked (i.e., zero them out)
DaysWorked:= 12 #MPSUM NetWorkingDaysInMth &
; accumulate the days worked in each month
HrsEarned:= 173.33 * (DaysWorked = #DAYSINMTH #DATE) &
; only in full months can you earn any hours
AnnualHrs:= -1 #MPSUM HrsEarned &
; Accumulated the net hours worked on a measurement period basis (e.g., accumulate by plan year),
; because the hours Service Definition determines service on a measurement period basis
AnnualHrs >= 1000
; (1) 0 indicates you didn't earn 1000 hours; 1 indicates you did earn 1000 hours (hence you get 1 year of service)
; (2) the result of the expression for each measurement period (i.e., plan year), must be the amount of service
; you earned in each measurement period. The Service Definition will accumulate the service earned in each
; measurement period and determine the total service earned.
; Note: if the measurement period was monthly, then you would want the final expression to return 1/12 (or less)
; of service each month.
There are many ways to calculate Working in the hours transformation expression (some that don't require setting up StartEventDates and StopEventDates). Please see How to determine if someone is working.