title: Get the first value of result of LookupSet if not null in SSRS for Dynamic 365
body: <p>I'm writing a report for Microsoft Dynamics 365 Version 1612 (8.2.2.113) which uses the following expression:</p>
  
  <pre><code>=IIF(LookupSet("Test", Fields!new_product_name.Value, Fields!new_product_code.Value, "Test_DataSet").Length = 0,
       "",
       LookupSet("Test", Fields!new_product_name.Value, Fields!new_product_code.Value, "Test_DataSet")(0)
   )
  </code></pre>
  
  <p>The idea is to return the code of first product with name as "Test", and return blank if there is no match.</p>
  
  <p>However, because IIF in SSRS does not short-circuited, even if there is no match, it will still try to get the first (index = 0) element from LookupSet and then throw an error.</p>
  
  <p>How can I archive what I'm trying to do?</p>