The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.

Forum Discussion

Jason's avatar
Jason
New Contributor II
4 years ago
Solved

Adding unique records to a Member List

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

  • 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

  • Jason's avatar
    Jason
    New Contributor II

    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()