Divide by Zero Workaround

@Tim_Reblitz I figured this out after I had some time to unwind after work.

First, I created two variables, one null, the other zero, and tried some math on them to see what combinations of numerator and denominator would fail.

Results:

  • null/null=null
  • zero/null=null
  • null/zero=null (unexpected)
  • zero/zero=trigger error

Previously I was trying to use an IF statement to check if my denominator was zero, and then try to get a null result instead of executing the division calculation, but I was getting argument datatype mismatch errors for some reason.

The simpler approach, after reflection, was to use NULLIF and check whether the value in the denominator =0, if so, division by null occurs, and the result is null (rather than an error).

Result: