Skip to main content
November 27, 2025
Solved

Removing Duplicates from a Member Filter

  • November 27, 2025
  • 2 replies
  • 0 views

Hi All, 

I have the following use case whereby in my parameter, I have a member list of C#Local,C#USD,C#JPY,C#|WFText2| whereby WFText2 will be currencies/consolidation members eg. CNY,EUR,SGD,USD,JPY

Is there a way to filter the member list to remove duplicates such that if WFText2 is USD, the memberlist will return C#Local,C#USD,C#JPY instead of C#Local,C#USD,C#JPY,C#USD

Any help is appreciated, thanks! 

Best answer by sameburn

Hi Kenn​

If you are working with a Member List you can use something like this Linq syntax (see vb example below).

** This assumes that we are using object Member in our list and therefore we can access Name property

Dim List(of Member) distinctByName = yourMemberList _
    .GroupBy(Function(p) p.Name) _
    .Select(Function(g) g.First()) _
    .ToList()

This will get the First instance of duplicate e.g C#Local in your example. If you want Last, simply change syntax to be .Last() instead 

Hope this helps

Sam

2 replies

November 27, 2025

I am assuming that when you say 'member list' you mean a text string that contains a list of members rather than an object which is List(Of Member). You can use a hashset for that like this:

Dim input As String = "C#Local,C#USD,C#JPY,C#USD"
' Split the string by commas
Dim members() As String = input.Split(","c)  

' Use a HashSet to filter unique members efficiently
Dim uniqueMembers As New HashSet(Of String)(members)

' Join back the unique members into a string
Dim result As String = String.Join(",", uniqueMembers)

 

sameburnAnswer
November 27, 2025

Hi Kenn​

If you are working with a Member List you can use something like this Linq syntax (see vb example below).

** This assumes that we are using object Member in our list and therefore we can access Name property

Dim List(of Member) distinctByName = yourMemberList _
    .GroupBy(Function(p) p.Name) _
    .Select(Function(g) g.First()) _
    .ToList()

This will get the First instance of duplicate e.g C#Local in your example. If you want Last, simply change syntax to be .Last() instead 

Hope this helps

Sam