title: Remove Duplicate Function with LookupSet returing #Error in SSRS
body: <p>In my <code>SSRS</code> Report, I am using <code>LOOKUPSET</code> function to <code>concatenate</code> one of the <code>field values</code> . In-order to get <code>distinct concatenated</code> values I used <code>RemoveDuplicates</code> Vb Function in Report Code.</p>
  
  <p>the <code>function</code> code is:</p>
  
  <pre><code>Public Shared Function RemoveDuplicates(ByVal items As Object())  As String()
  System.Array.Sort(items)
  Dim k As Integer = 0
  For i As Integer = 0 To items.Length - 1
  If i &gt; 0 AndAlso items(i).Equals(items(i - 1)) Then
  Continue For
  End If
  items(k) = items(i)
  k += 1
  Next
  Dim unique As [String]() = New [String](k - 1) {}
  System.Array.Copy(items, 0, unique, 0, k)
  Return unique
  End Function
  </code></pre>
  
  <p>My TextBox <code>Expression</code> is,</p>
  
  <pre><code>=Join(Code.RemoveDuplicates(LookUpSet(Fields!id.Value,
  Fields!id.Value,
  Fields!code.Value,
  "ds_DataSet1")), " , ")
  </code></pre>
  
  <p>This <code>expression</code> works fine in all the cases except <code>blanks</code>.If <code>Fields!code.Value</code> contain only blanks, Report Preview Returns the error <code>#Error</code> in the <code>field value</code>.</p>
  
  <p>When I removed the <code>RemoveDuplicates</code> function from the <code>expression</code>, it works fine for all the cases. Do I need to make changes in the <code>vb function</code> to incorporate blanks also? what I am missing here?</p>