# 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.

The actual performance impact could be smaller than the value shown, which is the maximum in the worst-case scenario. However, the use of IFERROR would hide any error, not just a division by zero: therefore, when IFERROR was used just to remove a division-by-zero error, it is always a good idea to use DIVIDE.

## 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
)
```