title: Prolem with IIF statement in SSRS
body: <p><strong>The Setup</strong></p>
  
  <p>I have an expression that converts all caps values to proper case. Some of the values have an extra bit preceded by a hyphen, I want everything before that. Sadly a <code>LEFT(INStr</code> expression errors on instances without a hyphen in.</p>
  
  <pre><code>=IIF(
        INstr(Fields!Introducer_Title.Value, "-") = 0, 
        StrConv(Fields!Introducer_Title.Value,vbStrConv.ProperCase), 
        "nope"            
        )
  </code></pre>
  
  <p>The above works just fine: if there is no hyphen then the string is converted to proper case, otherwise it just says nope.</p>
  
  <p><br></p>
  
  <p><strong>The Problem</strong></p>
  
  <pre><code>=IIF(
        INstr(Fields!Introducer_Title.Value, "-") = 0, 
        StrConv(Fields!Introducer_Title.Value,vbStrConv.ProperCase), 
        Left(StrConv(Fields!Introducer_Title.Value, VbStrConv.ProperCase), INstr(StrConv(Fields!Introducer_Title.Value, VbStrConv.ProperCase), "-")-1)        
        )
  </code></pre>
  
  <p>The above works in so far as that if there is a hyphen in the value it returns the text before it in proper case, but now the values without hyphens error. The logic hasn’t changed.</p>
  
  <p>It's as if instead of going IIF(A=TRUE,This,That) is somehow converted to <em>always</em> do That when I replace the Otherwise "nope" with a nested expression.</p>
  
  <p>The error is just #Error, no other information.</p>
  
  <p><br></p>
  
  <p>Am I missing something obvious? I have a feeling this is some quirk of SSRS.</p>
  
  <p><br></p>
  
  <p><strong>Updates</strong><br>
  This is getting stranger the more I look into it:</p>
  
  <ul>
  <li>Wrapping the function in an <code>ISERROR</code> is creating an error on the bad rows, rather than returning <code>true</code>.</li>
  <li>Using an <code>InStrRev</code> function is returning the same value as an <code>InStr</code> function even though the position of the hyphen in the first row is not in the middle (I checked the values in Excel)</li>
  </ul>