Absolute comparison use AsEnumerable

Hi,

How can I absolute comparison column 0 and codeToCompare because sometimes
column 0: C0392
codeToCompare : C0392 & C0392.(dot)

I want compare C0392 = C0392

dtDeposit.AsEnumerable.Where(Function(x)x(0).ToString.Equals(codeToCompare)).ToArray

HI,

Can you share specific input sample and expected result as file?

Regards,

1 Like

Hi @anh.nguyen

Try this:

dtDeposit.AsEnumerable.Where(Function(x) x(0).ToString.TrimEnd("."c).Equals(codeToCompare)).ToArray

Hope it helps!!

1 Like

hi,

Read Range DEPOSIT file = dtDeposit. have column 0 have : C00392…
For each row data dtARRSheetF assign codeToCompare column 0: have C00392, C00392.(dot)
Assign matchedRows = dtDeposit.AsEnumerable.Where(Function(x)x(0).ToString.Equals(codeToCompare)).ToArray

Condition: matchedRows.Length > 0
expected result: find dtDeposit(C00392) = dtARRSheetF (C00392) not C00392.(dot)

Thank you

Hi @anh.nguyen

Try this. It will work.

Regards

1 Like

Still compare not correct

image

@anh.nguyen
Your condition was C01120 must be equal to C01120 without dot right. Please clarify.

Regards

Yes, absolute comparison

@anh.nguyen

The condition i have written is to trim the dot at the end and compare with codesToCompare in the above query.
Please share an dummy data input excel file so that I can help you with that.

Regards

number of character of codeToCompare is fixed format?
i see in here is 5 characters

or
last character need remove it “dot” “.” ?

if they fixed you can use string
codeToCompare.Substring(0, 5)

or
Left(codeToCompare, 5)

FORM BANK.xlsx (9.3 KB)
ARR_20230822.xlsx (267.3 KB)

Send you

I see “Customer code” and
“Code(Mã khách hàng)”

->get left 6 will ok

Hi, can’t fix it because some have code C00965-01 (9char)

Oh, I think can use regex

Hi @anh.nguyen

Try this

dtDeposit.AsEnumerable.Where(Function(x) x(0).ToString.TrimEnd(".“c).Equals(codeToCompare.TrimEnd(”."c))).ToArray

It error
Multiple Assign: Can not assign ‘dtDeposit.AsEnumerable.Where(Function(x) x(0).ToString.TrimEnd(".“c).Equals(codeToCompare.TrimEnd(”."c))).ToArray’ to ‘matchedRows’.

Hi @anh.nguyen

Try this:

dtDeposit.AsEnumerable.Where(Function(x) x(0).ToString.Equals(codeToCompare).ToString.TrimEnd("."c)).ToArray

Regards,

It error
image