Expression: DivSafe
Introduction
DivSafe function in Sharperlight Expression provides you to prevent error caused by dividing n by 0.
So, let’s see how to use it.
Practices
Query Definition
Instead of querying the database, I prepare a custom dataset here.

The dataset definition looks like this.

Define outputs items.

The query result looks like this.

Adding DivSafe function
Add an expression and type ‘div’ in the Find textbox to search the template for the DivSafe function.

Double click it to transfer the template to Expression Formula text editor.

Use column reference (Name) to edit the template so that it will be;
DivSafe( {%dividend},{%divisor} )

Click OK to save, and rename the expression as ‘Result’.

Preview it, the query returns the result without error.

Afterword
DivSafe function returns 0 when n divided by 0.
On the other hand, when n is divided by 0 without using DivSafe, it returns the text ‘Attempted to divide by zero.’

Back to Expressions.
