Select query in datatable getting from Excel file

i have excel file with three column. Based on two value i have to get third value.

Make Model Type
SUZUKI GSX650F motorcycle

based on column1(Make) and column2(Model) find column3(Type)

Are you talking about doing a lookup table to populate column3?

or are you asking the use to provide (via an input dialog perhaps) make and model, with the bot then returning column3?

@pankajs3

Try below method:

   ForEach row in DataTableName

  If row("Make").Tosting.equals("SUZUKI") AND row("Model").Tosting.equals("GSX650F") 

  Then Assign Type = row("Type").Tostring
1 Like

@ronanpeter
based on column name when i provide column value then select either whole row or third column value from excel

How are you providing this input?

@lakshman
I don’t want to do using For loop
using of Datatable.select i want to get value

@ronanpeter
through any variable

@pankajs3

If we will use Select query then will get entire row.

DataTableName.Select(“Make = ‘SUZUKI’ AND Model = ‘GSX650F’”)

@lakshman
But it’s giving me Datarow.
when i convert it to String using output datatable it givem me value with column name.

@pankajs3

Yes it will give output as array of Datarow.

If you want output as dataTable then try like this:

DataTableName.Select(“Make = ‘SUZUKI’ AND Model = ‘GSX650F’”).CopyToDataTable

Then use Output DataTable activity to convert it into string.

but Output Data Table give
dataTable
selected row with column name rows
but i want only selected row

@lakshman
How to check where select query contain any row or not.
i am using this
DT1.Select(“Make = ‘SUZUKI’ AND Model = ‘GSX650F’”).CopyToDataTable.Rows.Count
it gives result “1”
but if i provide non existing value then it throw exception.

@pankajs3

If this count is greater than ‘0’ then it contains rows.

Yes, It will throw error because your dataTable does not contain any data rows in this case.

but it’s wrong that then my further progress will not run if exception occur.
How will i get 0 size or or any other output without any exception

@lakshman
It’s done
Array of(DataRow) rowArr = DT1.Select(“Make = ‘SUZUKI’ AND Model = ‘GSX650F’”);
if(rowArr.length > 0){
//working
}

Thanks @lakshman

2 Likes