How do I read a cell value and identify corresponding values in the row?

Hi guys, currently I have an input dialog to ask for a ID number, at which that variable I would want to use to search up in an Excel spreadsheet to identify the row and the other values in the same row. I then want to use those row values to create a generic message. How would I go about doing so? Thanks.

Hi @Xavier_Tan

Welcome to Uipath community

You can try with Look up DataTable activity

Check out the Video and docs

Regards
Gokul

Hello @Xavier_Tan
Welcome to the uipath community.
You can use a lookup data table.

  1. Read the excel sheet using the Read Range workbook activity and store the output as a DT
  2. Pass the DT in the Lookup data table activity.
    2.1 Mention the Column name and which value needs to lookup.
    2.2 In the property, use the target column to find the corresponding value in another row, Mention the column name.
    2.3 Output in a Cell value, can the corresponding values.

Hi @Xavier_Tan ,

Based upon the Generic message format, we could also go for an alternate method of using Linq Where clause to get the entire row values as a DataRow and then formulate the String in the required format.

rowData = DT.AsEnumerable.Where(Function(x)x("ID Number").ToString.Equals(idNumber)).FirstOrDefault

Here, DT is your Datatable value output from Read Range Activity, idNumber is a String type output from Input dialog activity and rowData is of type DataRow.

We could formulate the Generic String based on the availability of Data in rowData first by checking if content has a match in data.

rowData is Nothing                          //results in true if no match found

String formatting Example :

String.Format("Hi, My ID is {0}, My Name is {1}.",rowData("ID").ToString,rowData("Name").ToString)

image

Hi, thank you so much! I have been looking into it and it has worked for me!

Hi Supermanpunch,

Thank you so much for this alternative solution! I really appreciate the comprehensive example you provide. :slight_smile:

Hi @supermanPunch,

May i ask, based on this string, what activity do i input it into before putting out the string.format

Great @Xavier_Tan

Kindly close this topic by mark as solved. It will help for others too.

Regards
Gokul

@Xavier_Tan ,

This needs to be used within an Assign Activity where L.H.S is rowData variable and R.H.S will be the Expression.