I am trying to create custom code, coupled with an SSRS expression, that will allow me to display the number of distinct values in a lookupset array from another dataset ("Faults"). The expression in the target dataset ("Stations") will look like this:
=code.CountDistinct(Lookupset(Fields!StationNumber.Value,Fields!OpID.Value, Fields!OpID.Value, "Faults"))
Give this a try in the code for your report. I just modified the code a little from the other answer to return an integer which is the count of distinct values. Reference.
Public Shared Function CountDistinct(m_Array As Object()) As Integer System.Array.Sort(m_Array) Dim k As Integer = 0 For i As Integer = 0 To m_Array.Length - 1 If i > 0 AndAlso m_Array(i).Equals(m_Array(i - 1)) Then Continue For End If m_Array(k) = m_Array(i) k += 1 Next Return k End Function
I am not sure this code has changed enough to qualify as a new answer. I certainly don't want anyone to think I am plagiarizing any code.