Description
Use a date field create a variable that separates the date values into Months. For instance, a table showing enrollment status over the year (see below).
How To
Use the code below to create the calculated variable.
On Expression tab:
Exclude Previous Years Approach:
Modify the picklist options to include: 12 = Previous year, 13 = Missing date
function main() {
if(isNull(V1)) {
return 13;
} else {
var myMonth = V1.getMonth();
var myYear = V1.getYear();
if (myYear <= 2015) { // previous year = 2015, replace as appropriate
return 12;
} else {
return myMonth;
}
}
}
On the Pick List tab:
List months 0 to 12 (e.g., 0 = January, etc.; 12="Previous Year"; 13 = "Missing Date")
Alternate method that ignores the year:
In this example, don't need a pick list option for 12/Previous Year
function main() {
if (isNull(V1)) { // check to make sure the date field exists
return 13;
} else {
var myMonth = V1.getMonth();
return myMonth;
}
}