Knowledge Base
Open App
KB 101000

Function replace IFERROR/DIVIDE


The IFERROR function can be replaced by DIVIDE.

Remarks

The IFERROR function catches any error, including conversion errors. When the expression is a division operator, the error that is more likely to happen is a division by zero. The DIVIDE function specifically manages the division by zero condition without intercepting any other error, resulting in faster execution time.

DirectQuery

You can Ignore the issue if the model is in DirectQuery mode.

This optimization can be counterproductive in DirectQuery models. The IFERROR function is usually folded into a query to the underlying database, whereas the DIVIDE function is not. Therefore, this optimization should be used only when the model is in Import mode.

Example

Replace the IFERROR function with DIVIDE, moving the denominator expression in the second argument of DIVIDE. The second argument of IFERROR becomes the third argument of DIVIDE.

Original code

IFERROR (
    [Amount] / [Quantity], 
    0
)

Possible optimization

DIVIDE (
    [Amount],
    [Quantity],
    0
)