Make badval() in Formula data reference equivalent to BadVal() in Analytics
Currently, BadVal() in Asset Analytics can handle situations like BadVal(1/0) without throwing a divide by zero error, but the badval() function in the Formula DR cannot. The request is to make them equivalent so that behavior is consistent across the product.
Thank you for your feedback.
Rick Davin commented
Issue documented here: https://pisquare.osisoft.com/thread/42973-badval-doesnt-detect-divide-by-zero-errors
Problem with formulas is that badval(1/0) will evaluate the 1/0 first and throw a divide by zero error before badval has a chance to evaluate.
Simon J. Dyson commented
BadVal should return TRUE if the input argument has a bad quality. So for a PIPoint DR this would be when the value is a digital state (for numeric), or digital state outside the digitalstate set, including system states. For formulas, I would expect that things such as "divide by zero", "all events filtered", "no events", "No data", "unknown attribute" etc etc would be treated as bad values. In the same way as the IFERROR function works in Excel.
BadVal should do what it says it should, i.e. detect when the argument is bad. This saves a lot of defensive logic to be added to the formulas when it should be a standard function.
Agree that they should behave the same. Which is the desired behavior?