3 Replies Latest reply on May 15, 2014 4:00 PM by philmodjunk

# Help with If Statement with values between two other values

### Title

Help with If Statement with values between two other values

### Post

I have a set of zip codes that i am trying to organize by zone.

ie: If zip code is between 00001 < Zip Code < 19999 then result is zone 1

and If zip code is between 20000 < Zip Code < 29999 then result is zone 2

and If zip code is between 30000 < Zip Code < 39999 then result is zone 3

and If zip code is between 40000 < Zip Code < 49999 then result is zone 4 etc...

I would like to know if there is a way to create a script or statement that would do the following. Any help with the matter would be greatly appreciated. I hit a wall and can't move forward

• ###### 1. Re: Help with If Statement with values between two other values

Case ( ZipCode < 19999 ; 1 ;
Zipcode < 29999 ; 2 ;
ZipCode < 39999 ; 3 ;
ZipCode < 49999 ; 4 ;
and so forth....
)

is one possibility. Here's another:

Max ( Div ( ZipCode ; 10000 ) ; 1 )

• ###### 2. Re: Help with If Statement with values between two other values

What if the case is between two values

ie: If zip code is between 00001 < Zip Code < 12999 and 14000 < zip code < 15999 then result is zone 1

and zip code is between 13000 < Zip Code < 13999 then result is zone 2. Your help is greatly appreciate it

• ###### 3. Re: Help with If Statement with values between two other values

Both calculations still work.

This works in the Case function because case starts with the first Boolean expression, ZipCode < 19999, evaluates it and then only tries the next Boolean expression if the previous one does not evaluate as True. Thus, it never checks to see if the value is less than 29999 until the previous test confirms that it is not less than 19999. Thus 2 will be returned for all values from 20000 to 29999.

Try them and see for yourself.