Description
Use a date field to create a variable that separates the date values into Months. For instance, a table showing enrollment status over the year (see below).
...
Use the code below to create the calculated variable.
Variable Finder tab: Add a date variable by which the data will be grouped (columns)
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
return 14;
} else {
var myMonth = V1.getMonth() + 1; // JavaScript has Jan=0, Feb=1, etc., thus add 1 so that Jan=1, Feb=2, etc.
var myYear = V1.getFullYear();
if (myYear <= 20152016) { // previous year = 20152016, replace as appropriate
return 1213;
} else {
return myMonth;
}
}
}
On the Pick List tab:
List months 0 to 12 Create (e.g., 0 1 = January, 2 = February, etc. ; 12through 13="Previous Year"; 13 14 = "Missing Date")
Alternate method that ignores the year:
...