I'm trying to make a calculation that checks if a number is within the following range of numbers:

- 0 to 20,833

- 20,833 to 33,332

- 33,333 to 66,666

- 66,667 to 166,666

- 166,667 to 666,666

- 666,667 and above

If the number (n) falls within any of the specified range (except the first range which will always return a value of 0 and the second range which doesn't have a predetermined value), it will perform a calculation that requires to return the value of (n) subtracted from the smallest number in the range multiplied by a given percentage rate (red). (Ex. 45,678 - 33,333 x 25% = 3,086.25). Which will then be added to a predetermined value (blue). (Ex 3,086.25 + 2,500 = 5,586.25).

This is what I tried but it only works with the first and second ranges. Anything higher fails to return the correct result:

Case (

n ≤ 20833 ; 0 ;

n > 20833 & n < 33333 ; n - 20833 * .2 ;

n > 33332 & n< 66667 ; 2500 + (n - 33333 * .25) ;

n > 66666 & n < 166667 ; 10833.33 + (n - 66667 * .3) ;

n > 166666 & n < 666667 ; 40833.33 + (n - 166667 * .32) ;

n ≥ 666666 ; 200833.33 + (n - 666667 * .35) ;

)

I am relatively new to Filemaker and scripting. Any help or advise is well appreciated.

Here is an example of what I was describing.

You also need to check the calc as it needs an additional set of parenthesis to be correct.

Const + ((n - low) * multiplier)