---
title: "How to handle divide-by-zero errors in SSRS expressions?"  
description: "How to handle divide-by-zero errors in SSRS expressions?"  
author: "Anubhav Sharma"  
published: 2026-09-01  
updated: 2026-09-01  
canonical: https://answers.mindstick.com/qa/117137/how-to-handle-divide-by-zero-errors-in-ssrs-expressions  
category: "SSRS"  
tags: ["ssrs", "expressions", "error-handling", "reporting-services"]  
reading_time: 1 minute  

---

# How to handle divide-by-zero errors in SSRS expressions?

When writing expressions that divide numbers in SSRS, you may notice that using a simple `IIF` statement still results in a `#Error` when the denominator is zero:

```
=IIF(Fields!TotalSales.Value = 0, 0, Fields!Revenue.Value / Fields!TotalSales.Value)
```

### Why does this fail?

In Visual Basic / SSRS expression evaluation, both the *True* and *False* parts of an `IIF` function are evaluated prior to returning a value. Therefore, division by zero occurs regardless of the condition check.

### Correct Workaround:

```
=IIF(Fields!TotalSales.Value = 0, 0, Fields!Revenue.Value / IIF(Fields!TotalSales.Value = 0, 1, Fields!TotalSales.Value))
```

Replacing the denominator with 1 in the false branch prevents the evaluation engine from dividing by zero.


---

Original Source: https://answers.mindstick.com/qa/117137/how-to-handle-divide-by-zero-errors-in-ssrs-expressions

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
