Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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).

 


How To

Use the code below to create the coded calculated variable.  Remember this ignores year!

 

Image Removed

Image Removed

 calculated variable.  

Variable Finder tab:  Add a date variable by which the data will be grouped (columns)

On Expression tab:

Exclude Previous Years Approach:

 function main() {

   if (isNull(V1))  {

         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 <= 2016) {        // previous year = 2016, replace as appropriate

           return 13;     

     } else {

           return myMonth;

     }   

 }

}

On the Pick List tab:

Create  (e.g., 1 = January, 2 = February, etc. through 13="Previous Year"; 14 = "Missing Date")

 Image Added

 Image Added

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;

}

}