How to get the name for a maximum or minimum value from a table

Screenshot 2022-11-16 090034

I am trying to get the bank name with the lowest value from vs BNM (Buy) and put it into the To Buy, may I know how can I do this using UI path?

@hjie30
Welcome to UiPath Community.
Read the excel and store it in datatable
minVal = dtFiltered.AsEnumerable.Min(Function (x) CDbl(x(“vsBNM(Buy)”).toString.Trim))
maxVal= dtFiltered.AsEnumerable.Max(Function (y) CDbl(y(“vs BNM(Buy)”).toString.Trim))

Write max value or min value in the respective cell in excel.

1 Like

Hi,

How about the following sample?

Sample20221116-5.zip (9.6 KB)

Regards,

1 Like

May I know what type should I give my arrayDR?

May I know what’s the problem I encountered?

@hjie30 What is the datatype of minval?.Change it to double and try again

Hi,

Can you try to set DataRow array?
DataRow()

Regards,

Okay the data type change fixed the issue, but now I have another issue with the column “vs BNM (Buy)” May I know how to solve it? The vs BNM (Buy) is present in table sheet1, I even copy the column name but seem like doesn’t work

Hi,

As the table starts from B4, it’s necessary to set the following In ReadRange?

Excel.Sheet("Sheet1").Range("B4")

OR

 Excel.Sheet("Sheet1").Range("B4:G9")

Regards,


Okay it works! thanks a lot Yoichi. I have another issue is that how do I exclude the Bank BNM for minimum and maximum calculation?

Thanks Sangeetha for the solution but I think I will stick to Yoichi’s solution

1 Like

HI,

Can you try the following expression?

dt.AsEnumerable.Where(Function(r)r("Bank").ToString<>"BNM").OrderBy(Function(r) Double.Parse(r("vs BNM (Buy)").ToString)).ToArray()

Regards,

Thank you very much Yoichi, you solved all my issue. Have a nice day!

1 Like

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