### Title

Greater than or equal to in a case statement

### Post

Im using a case statement to set the value of a varable. I have 5 weight breaks i need it to check for a true statement.

This is an example of one of them: If the weightfromquote = 5643 then set the varable to the filed that is greater than or equal to 5000 and less than or equal to 9999.

This is my expression:

Set varable [$setweightmultiplier;value:

Case ( Rate Calculation::Weightfromquote *_> 5000 and *_< 9999 ; Rate Calculation::Base_Rate_5000)

*I don't know how to get my keyboard to de greaterthan or equal to sooo.. i used _>...

This expression does not work.

I tried

Case let ([~num = (RateCalculation::Weightfromquote)]; ~num _> 5000 and ~num 9999) ; Rate Calculation::Base_Rate_5000;

It will recognize the greater than or equal to phrase but not the case of setting the $getweightmultiplier to the Rate Calculation::Base_Rate_5000

What am i doing worng?

First, some basic syntax. If you want to use a single expression to see if a value is within a range, write it like this:

Rate Calculation::Weightfromquote > 5000 and Rate Calculation::Weightfromquote < 9999

Note that you refer to the date field twice, once for each inequality. (I used underline formatting to get the right look. It won't copy and paste accurately into fileMaker.)

But since you have a series of values and a case function, you don't actually need to use two sets of inequalities like this. A case function returns the value paired with the first expression that evaluates as true, you can set up a series of increasing or decreasing values to test for:

Let ( w = Rate Calculation::Weightfromquote ;

Case ( w < 1000 ; /* Rate for weight less than or equal to 1000 here */ ;

w < 2000 ; /* Rate for weight more than 1000 and less than or equal to 2000 here */ ;

w < 3000 ; /* Rate for weight more than 300 and less than or equal to 3000 here */ ;

and so forth...

) // close the case function

) // close the let function

Even this approach isn't necessarily ideal. You can also set up a table look up that looks up these rates from a related table. Such a table of rates can be easily modifiied and the changes would only affect data in new records, so you can change rates without altering historical data.