Subscribe Bookmark RSS Feed

If-function else-clause not recognizing missing values

JesperJohansen

Community Trekker

Joined:

Apr 15, 2013

If I add an If-function  to a column, the else-clause does not recognize empty values (see attached sheet). this means that the function:

If( :Column 2 == 1, 1,

2 )

leaves missing values if Column 2 contains missing values. I can fix this by changing the function to:

If(  :Column 2 == 1, 1,

  Is Missing( :Column 2 ), 2)

or

If(  :Column 2 == 1, 1,

  Is Missing( :Column 2 ), 2,

  2)

but why is this necessary? Is it a bug or a deliberate "feature"?

BR
Jesper
3 REPLIES
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

This behavior is intentional and is associated with the propagation of missing values. Your can read a bit about it in the Conditional Functions section of the JMP Scripting Guide.

You should always include a check for missing values in your conditionals.

-Jeff

-Jeff
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

If you want to understand why it behaves this way, run this code in your head (and then try it in JMP):

x = .;

If( x < 5, Show( "X is less than five" ),

x>5, Show( "X is greater than five" ),

Show("X is equal to five")

);

What did you think it would do?

-Jeff
JesperJohansen

Community Trekker

Joined:

Apr 15, 2013

I think I came to the same conclusion upon more consideration. That "missing" is not the same as "X is equal to five" in your example. Or whatever else may be placed in the "else" clause.

Thank you

BR
Jesper