How to put where condition in a remove duplicate queries

Hi,
I have queries to combine row 10 and 11 to remove duplicate:

(From d In NewDT
Group d By k1=d(10).toString.Trim, k2=d(11).toString.Trim Into grp=Group
Select grp.First()).toList

How i can add where condition on the queries if i only want to remove duplicate if row 11 not null? If row 11 is empty then no need to group with row 10.

Hi @mashy2 ,

Could you try this instead?

(From d In NewDT
Group d By k1=d(10).toString.Trim + k2=d(11).toString.Trim Into grp=Group
Select grp.First()).toList

You could try combining them and see if that produces the required output.

Kind Regards,
Ashwin A.K

if put + then need to declare the k2, what variable should i declare?

Hi @mashy2

Try this expression to remove Duplicate based on two rows

(From p in DtMaster.Select() where( From q in DtMaster.Select() where q(10).Equals(p(10)) AndAlso  q(11).Equals(p(11)) Select q).ToArray.Count>1 Select p).ToArray.CopyToDataTable()

Regards
Gokul

Oh sorry my bad, I meant to only reference a single grouping like so →

(From d In NewDT
Group d By k=d(10).toString.Trim + d(11).toString.Trim Into grp=Group
Select grp.First()).toList

Kind Regards,
Ashwin A.K

how if i just need to specify only group row 10 and 11 if row 10 doesnt contain " -"

we would recommend to visualize it with sample data

especially we are interested on the cases and detail requirements:

And

also show us the expected output for the input sample. Thanks

hi, this is input:

image

and my expected output is:

image

This mean its only remove duplicate rows for column Value A that not empty