title: SSRS 2008 - Dealing with division by zero scenarios
body: <p>We're running into a problem with one of our reports. In one of our tablixes a textbox has the following expression:</p>
  
  <pre><code>=Iif(Fields!SomeField.Value = 0, 0, Fields!SomeOtherField.Value / Fields!SomeField.Value)
  </code></pre>
  
  <p>Which should be pretty self-explanatory. If "SomeField" is zero, set the text box value to zero, else set it to "SomeOtherValue / SomeValue".</p>
  
  <p>What has us stumped is that the report still throws a runtime exception "attempted to divide by zero" even though the above expression should prevent that from happening.</p>
  
  <p>We fiddled a bit with the expression just to make sure that the zero-check is working, and</p>
  
  <pre><code>=Iif(Fields!SomeField.Value = 0, "Yes", "No")
  </code></pre>
  
  <p>works beautifully. Cases where the data is in fact zero resulted in the textbox displaying "Yes" and vice versa. So the check works fine.</p>
  
  <p>My gut feel is that the Report rendering engine throws the exception at run-time, because it "looks" as if we are going to divide by zero, but in actual fact, we're not.</p>
  
  <p>Has anyone run into the same issue before? If so, what did you do to get it working?</p>