# Get Excel Records Based on Conditions

Hello,
I want to fetch rows from excel using UiPath.

So, the data table has three column: “Name”,“LastDay” and “CashValue” and 10 records.

I want to get the record of Name “A” only if both 1 and 2 condition meets

1. Min Value of “LastDay” is less then 10 AND
2. Sum Value of “CashValue” is more than 1000.

Regards,
Geet M

1 Like

Hi @iamgeet,

Can you try using below code and see if it helps?

`filteredDT = DT1.AsEnumerable.Where(Function(row) Convert.ToInt32(row("LastDay")) < 10 AND Convert.ToInt32(row("CashValue")) > 1000).CopyToDataTable`

Here is my test data:

Hello,

Thank you for response.

I just wanted to understand the meaning of this line of code…" Convert.ToInt32(row(“CashValue”)) > 1000) ", does it mean…

1. It check of any value is greater than 1000 under this column “CashValue”?
OR
2. It add all the values (1000+10001+900…) under this column "CashValue and then checks for sum >1000?
I am looking for the 2 thing, Like I want to add and then I want check its sum>1000.

Regards,
Geet M

As per my understanding, the code given @jcastro checks only for cashvalue greater than 1000.
Regarding your second condition, the sum value will always be greater than individual cash value for a specific name , right?

1 Like

Like, First I will add all the values there in “CashValue” and then Suppose the sum of all is 500000 then I will check whether sum>50000

and Also I have to get the what is the min value in “LastDay” and then I have to check the min value is <10.

Regards,
Geet M

yes for a specific name

From yours 1st point, it looks like the sum of cash value will always be greater than any individual cash value, isn’t it?
Correct me if I am wrong.

yes.
Let me take this Example

For Name “A”:
I will do steps 1,2,3 as explained in diagram.

Regards,
Geet M