Filter by Length and delete duplicates

Hello everybody,

From my datable ‘dt’ i want modify my column “Famille d’achat” by keep only the 4 firsts characters.

And i want delete duplicate rows where my column “Famille d’achat” and “Recu” is similary.

Can you help me … ?

Thank !

Hello @mateo.drouillard ,

Can you share a screenshot of the Current excel and the required output excel. It will be easy to udnerstand.

Yes !

CURRENT :
image

AFTER :
image

Hello @mateo.drouillard ,

You can refer the below post.

So after setting the length of values to 4, you use a Remove Duplicate Row to delete the duplciates.

1 Like

dtFiltered =

(From d in dtData.AsEnumerable
Group d by k1=d(0).toString.Trim.Substring(0,4), k2=d(1).toString.Trim into grp=Group
Select g = grp.First()).CopyToDataTable
2 Likes

Thank but, i dont understand how keep the length of values to 4.

And i can’t use remove duplicate rows because i have other column in my dt.

I Want delete rows where “Famille” + “Reçu” is égal.