Subscribe Bookmark RSS Feed

Help debugging a conditional statement with IsMissing

jswislar

Contributor

Joined:

Nov 17, 2016

This formula *seems* OK to me, but it's not giving me what I want, so something is wrong. I'm trying to say that if:

Var1=. and Var2 >= 0 (i.e., not missing), then Var3=1

Var2=. and Var1 >= 0, then Var3=2

else (if Var 1 & Var2 are not missing) Var3=3

 

What I get is Var3=3 when Var 1 & Var2 are not missing as expected, BUT

Var3=1 if EITHER Var1 OR Var2 are not missing. There is only one case where Var3=2 even though there should be a LOT more. That case is Var1=0, Var2=.  

 

Here is the formula for Var3:

 

If( Is Missing( :Name( "Var1" ) & :Name( "Var2" ) >= 0 ),

1,

If( Is Missing( :Name( "Var2" ) & :Name( "Var1" ) >= 0 ),

2,

3

)

)

 

1 ACCEPTED SOLUTION

Accepted Solutions
jswislar

Contributor

Joined:

Nov 17, 2016

Solution
Hmm. I ran it again and it works. Maybe it got hung up halfway through running the script. I can't figure out how to delete this post.
2 REPLIES
jswislar

Contributor

Joined:

Nov 17, 2016

Solution
Hmm. I ran it again and it works. Maybe it got hung up halfway through running the script. I can't figure out how to delete this post.
markbailey

Staff

Joined:

Jun 23, 2011

Check your parentheses. Also, I do not see why you would use the Name() directive in this case. Finally, nested If() functions are unnecessary.

If(
	Is Missing( "Var1" ) & Not( Is Missing( "Var2" ) ),
		1,
	Not( Is Missing( "Var1" ) ) & Is Missing( "Var2" ),
		2,
	Not( Is Missing( "Var1" ) ) & Not( Is Missing( "Var2" ) ),
		3,
	.
)
Learn it once, use it forever!