How to get values based on column name

Hi,
Kindly suggest me How to get values based on column name

Thank you,

lets assume you can rely on the structure then you could slice the tables into pieces in order to get a name, value structure

e.g. take Col1,Col3, take Col5, Col7…

hi @seti.nadeem !

You have multiple options, will explain 2 of them below:

If you want a specific single value, you can use the following syntax:

  • Example: You want to get "kumar"
  • First read the DT with a Read Range activity , and to get that cell value, you would do the following:
  • *It seems that your data is not structured with column names, therefore you can use “coordinates”

- Important: DT start with index 0 on both rows and columns

var_DataTable.Rows(1).Item(2)
Or
var_DataTable(1)(2)

It is recommended to work in Column-Based DT, since with coordinates, if you ever have a formatting change, the coordinates might point to a wrong cell, but looking at your input, and if it is always structured like that, this would work.

If by “Columns” you refer to your 1st Row item: (Name, last name, Date, Amount) What you can do is a for each row activity, and when the following condition is true (If Activity)

row(0).toString.Equals("last name") → Where “0” is the 1st column

then take

row(2).toString → Where “2” is the 3rd column

→ This would return “Kumar”

If we use For Each row in datatable we get value row by row and then we can get all values that comes below names column or ramesh colums or age colums.

but in this case I want to access all values right to names, all values right to last name all values right to date and amount.

I hope it is clear now.

Thank you,
Akhtar Nadeem

Hi @seti.nadeem , you can use the Lookup Data Table activity, to find the row index, and then use that index to get your desired value:


image
image

I did put columnindex as variable, since I noticed that on column 5, you have another set of “names” like Age, desig or no.exp.

If you’d like to check on that column, just changing the “0” to “4” would work.

The “+2” on the following expression, is to point directly to the value that we want, skipping the empty value in the middle. this would also work on the 5th column.
DataExtract.zip (44.4 KB)