How to get row with highest value in row 0 and active in last row

abc.XLSX (8.5 KB)
in the final output I want
image
this yellow part as a result.

Hey

give a try with

Left Assign drResult (Type DataRow)

dtInput.AsEnumerable().Where(Function(r) r(5).ToString().ToUpper().Equals("ACTIVE")).OrderByDescending(Function(x) CInt(x(0))).FirstOrDefault()

Regards

its works, but I want the result in data table form because I have to write the result in another write range.

Hey

just change it a little bit, kindly try this
LeftSide yourDTResult

dtInput.AsEnumerable().Where(Function(r) r(5).ToString().ToUpper().Equals("ACTIVE")).OrderByDescending(Function(x) CInt(x(0))).Take(1).CopyToDataTable

Regards!

dtInput=dtInput.AsEnumerable().Where(Function(r) r(5).ToString().ToUpper().Equals("ACTIVE")).OrderByDescending(Function(x) CInt(x(0))).FirstOrDefault().CopyToDataTable()

Regards,
Arivu

1 Like

ThankYou :star_struck:

Can you please tell me how to learn this type of code?

Sure, please check @ppr perfil, he had post lot of tutorials about linq

Regards

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.