Post

3 followers Follow
0
Avatar

Calculate only when Category is selected

HI!   I need my MONTHS WORKED calculation to display ANYTHING other than a number when the Category TERMINATED is selected within Employment Status.  Any ideas on how to do this?

Esti Brooks

Please sign in to leave a comment.

2 comments

0
Avatar

Hi Esti,

var status = @Employment Status;
var a = moment();
var b = moment(@Employment Span);
status == "TERMINATED" ? a.diff(b,'months") : ""

That shows the difference between the moment the status TERMINATED is pressed and the start date of Employment Span. 

Rainer 

Rainer Grabowski 0 votes
Comment actions Permalink
0
Avatar

I think your problem here is that your calculation field will only update anytime the "Employment Span" is updated. 

 

To get your desired result, you'd want to have the whole thing contained in a conditional like this:

 

if(@Employment Status == 'TERMINATED'){

      //YOUR CODE GOES HERE

     write = a.diff(b,'months')

}

else{

      write = null

}

Aaron Jake Biehl 0 votes
Comment actions Permalink