none
try otherwise doesn't catch error RRS feed

  • Question

  • trying to do simple divide/0 catch, and the following returns NaN values:

    =try [miles] / [hour] otherwise null

    it does fine for all the records where hour=0, but for four records where miles=0 AND hours=0, it returns NaN instead of null

    aside from looking for cases where miles=0 and filtering them out, how can I catch this with 'try'?

    thanks!

    Sunday, October 22, 2017 8:20 PM

Answers

  • You can't use try because a value (NaN) is returned, and not an error. You have to test for the value like: if Number.IsNaN([miles] / [hour]) then null else [miles] / [hour].

    Also, any non-zero value of miles with a zero value for hour does not generate an error, but a different value, i.e. infinity.

    So your test should be: if Number.IsNaN([miles] / [hour]) or Number.Abs([miles] / [hour]) = #infinity then null else [miles] / [hour]

    Sunday, October 22, 2017 10:16 PM