Skip to main content
May 17, 2022
Solved

Adding unique records to a Member List

  • May 17, 2022
  • 1 reply
  • 0 views

Hello-

I have created a business rule that uses a buffer to bring back UD1 members that have a value against them, then they are added to a list like this:

myList.Add(api.Members.GetMember(DimType.UD1.Id, curUD1))

Later on in my code I do a sort Ascending, and return the results back to a cube view:

objMembers = (From member In myList Order By Member.Name Ascending Select Member).ToList()

I'm encountering a problem with duplicate values in the results.  This is because a small number of UD1 members have activity booked against them across more than one of the entities I am processing.

Are there any quick solutions to removes the duplicates in the add to list or sort steps?

The only thing I can think of would be to check if the value exists in the list before I add it, but that would require more coding.

Thanks

Best answer by Jason

I got this working, the fix was simple.  

On the sort line just add a Distinct()

The code becomes:

objMembers = (From member In myList Order By Member.Name Ascending Select Member).Distinct().ToList()

1 reply

JasonAuthorAnswer
May 17, 2022

I got this working, the fix was simple.  

On the sort line just add a Distinct()

The code becomes:

objMembers = (From member In myList Order By Member.Name Ascending Select Member).Distinct().ToList()