Filter and display duplicates in a list

Hi all!

I am trying to create a function that is able to find and filter duplicate strings/values within or between 1 or more lists.

Any good suggestions?

Thanks!

Hey @Josh_Whitchurch !

To remove duplicates within 1 list, you can use this:

{=unique([1, 2, 3, 2, 4, 4])}

Can you give an example for removing duplicates that are between more than 1 lists?

1 Like

Hey Gaurang,

Thanks for the response! I am actually look to maintain only the duplicate values vs removing them via the "unique" function.

I essentially want to be able to identify duplicates in a list.

Let me know if you have any good ideas to solve for this or if you'd like examples of what I am trying to accomplish.

Ah, okay. How about this? :slight_smile:

{mylist=[1, 2, 3, 2, 2, 4, 4]}
{all_duplicates=filter(mylist, (val, ind) -> location(mylist, val) <> ind); trim=yes}
{unique_duplicates=unique(all_duplicates); trim=yes}
My list is: {=mylist}
Duplicates are: {=all_duplicates}
Unique duplicates are: {=unique_duplicates}

The logic is to extract all values whose first index in the list does not match their current index. For example, in the case of the repeated value of 2, its current index (4th position) does not match its first index (2nd position).

Yes, this is what I needed! Thank you!