6 Replies Latest reply on Dec 11, 2013 5:02 AM by ryandunne_1

# if field <4 and >2 ?????

### Title

if field <4 and >2 ?????

### Post

basicly i have a series of if and if else statements

i want

if field greater than or equal to 1 and less than or equal to 10  set field to x

if else field greater than or equal to 11 and less than or equal to 20 set field to y

so on and so forth ive tried to do this and it just returns the first value every time

• ###### 1. Re: if field <4 and >2 ?????
Make sure the field with your variable in is set to Number.

The calculation in the result field should look like this:

If ( YourVariable ≥ 1 and YourVariable ≤ 10 ;
"x" ;
If ( YourVariable ≥ 11 and YourVariable ≤ 20 ;
"y" ;
"z"

) )

• ###### 2. Re: if field <4 and >2 ?????

i missed out a wee bit that if its true it runs another script step and if fails it goes to the next if statement, ill show you what i've got.

If [ import::product = "440 GSM PVC" ]
If [ import::UNITS = "FEET" ]
Set Field [ import::SQFOOT; import:: height*import::width ]
If [ import::SQFOOT ≥ 1 and import:: SQFOOT ≤ 6 ]
Set Field [ import::price; import:: SQFOOT * 2 ]
Else If [ import::SQFOOT ≥ 7 and import::SQFOOT ≤ 12 ]
Set Field [ import::price; import:: SQFOOT * 2 ]
Else If [ import::SQFOOT ≥ 13 and import::SQFOOT ≤ 20 ]
Set Field [ import::price; import::SQFOOT * 1.8 ]
Else If [ import::SQFOOT ≥ 21 and import::SQFOOT ≤ 60 ]
Set Field [ import::price; import:: SQFOOT * 2.5 ]
Else If [ import::UNITS = "METRES" ]
Set Field [ import::price; import:: height * import::width * 22 ]
End If
End If

End If

• ###### 3. Re: if field <4 and >2 ?????

Case would be simpler than IF - Else IF - End

If [ import::UNITS = "FEET" ]
Set Field [ import::price; ; Case (
import::SQFOOT ≥ 1 and import:: SQFOOT ≤ 6 ; import:: SQFOOT * 2;
import::SQFOOT ≤ 12 ; import:: SQFOOT * 2 ;
import::SQFOOT ≤ 20 ; import::SQFOOT * 1.8 ;
import::SQFOOT ≤ 60 ; import:: SQFOOT * 2.5
) // Case ]
Else If [ import::UNITS = "METRES" ]
Set Field [ import::price; import:: height * import::width * 22 ]
End If

You could also set up a related table of values to look up instead of using a calculation and then if the need to modify the values occurs, you can edit the values in the table--a simple data entry task, instead of having to redefine a calculation in a script--a task that requires the developer.

• ###### 4. Re: if field <4 and >2 ?????

ok i coppied that word for word and it seems to only be mutliplying by 3 again

• ###### 5. Re: if field <4 and >2 ?????

Case (
import::SQFOOT ≥ 1 and import::SQFOOT ≤ 6 ; import::SQFOOT * 3;
import::SQFOOT ≤ 12 ; import::SQFOOT * 2 ;
import::SQFOOT ≤ 20 ; import::SQFOOT * 1.8 ;
import::SQFOOT ≤ 60 ; import::SQFOOT * 2.5
) // Case ]

• ###### 6. Re: if field <4 and >2 ?????

Better check the value and data type of SQFOOT. Make sure that it is of type Number, not text.