SQLTeam.com | Weblogs | Forums

Need help writing maximum life insurance expression

Hello all!

Hoping to get help for writing an expression for our HRIS benefits module. The maximum amount of life insurance coverage offered is the lesser of $500,000, or 7 X base salary. So, if base salary is $71,428.58 or higher, coverage is $500,000. Otherwise, it is 7 X base salary.

Using the program's expression builder, this is what I was able to do on my own. No idea how accurate it is:
if (BaseCompx > 71428) { return 500000; } else { return BaseComp * 7; }

The system gives an error with that expression. Could anyone help me correct it please?

I won't try to diagnose your error, which you don't even show. I do see two problems, though.

  1. You're doing integer arithmetic on money values. Very bad.
  2. You have the multiple of 7 embedded in that expression twice, once as an explicit 7, the other time as the relationship 71428 and 500000. If any of those values change, multiple changes to the code will be necessary.