Excel get value from Excel based on other value

I have a Excel from which I have to fetch a value.

I will get month name as input and I have to return output based on input.
For Example I will get input as May and I have to return 34 as output from yellow sales column.

Hi @ravig1206

Read the excel using Read range activity

iterate excel file using for each datatable activity

use if condition to check month = input_String_variable (Ex : Currentrow(“Month”).ToString=input_String_variable
inside the then block
use this syntax to find yellow sales
syntax output_variable = Currentrow(“Yellow sales”).ToString
use the output variable whenever you want


I have already read the Excel into datatable variable the problem is I do not want to loop throught it because data in Excel is huge so is there any possibility to get this data without looping.

Hi @ravig1206

Try out this syntax

List_var=(((From dr As Datarow In dt
Where Convert.ToString(dr(“Month”))=Input_String_Variable
Select Convert.ToString(dr(“Yellow sales”))).ToList()).Distinct()).ToList


Hi Robin,

Thanks for your reply but this is not perfect solution because this is returning multiple values that to in list variable.

I have figured out solution my self.

We can use below query

Convert.ToString(Dt.select(“Month=‘May’”)(0)(“Yellow sales”))

This is working perfectly.

Thanks for your replies.

1 Like

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