Page 1 of 1

I have to use "in" condition within "if"

Posted: Wed Apr 08, 2009 5:53 am
by deesh
Hi,
Can any one help in this case,

if OKCUA4='' and OKCUA3 in (counties) then OKCUA2
else if OKCUA4='' and OKCUA3 not in (counties) then OKCUA3
else if OKCUA4 in (counties) then OKCUA3
else OKCUA4

Posted: Wed Apr 08, 2009 5:58 am
by shalini11
if OKCUA4='' and (OKCUA3=counties1 or OKCUA3=counties2...) then OKCUA2
else if OKCUA4='' and (OKCUA3<>counties1 or OKCUA3<>counties1 ...)then OKCUA3
else if (OKCUA4=counties1 or OKCUA4=counties2...)then OKCUA3
else OKCUA4

Posted: Wed Apr 08, 2009 6:50 am
by Mike
If you have a manageable number of counties, then you can use the approach suggested by shalini11. If you have hundreds or thousands of counties to check, then you'd want to use the lookup stage to implement your "in" and "not in" logic.

Mike

Posted: Wed Apr 08, 2009 10:04 am
by DSguru2B
Or maybe the index function.

Posted: Thu Apr 09, 2009 8:36 am
by kandyshandy
shalini11 wrote:if OKCUA4='' and (OKCUA3=counties1 or OKCUA3=counties2...) then OKCUA2
else if OKCUA4='' and (OKCUA3<>counties1 or OKCUA3<>counties1 ...)then OKCUA3
else if (OKCUA4=counties1 or OKCUA4=counties2...)then OKCUA3
else OKCUA4
It should be AND, not OR

if OKCUA4='' and (OKCUA3=counties1 or OKCUA3=counties2...) then OKCUA2
else if OKCUA4='' and (OKCUA3<>counties1 AND OKCUA3<>counties1 ...)then OKCUA3
else if (OKCUA4=counties1 or OKCUA4=counties2...)then OKCUA3
else OKCUA4

Or DSGuru's Index idea.