cancel
Showing results for 
Search instead for 
Did you mean: 

Find Any Value inside a collection to return row and column Index

VivekGoel
Level 10

Problem Statement: If a Collection has Columns named as "Name", "Age" and "Sex" , and it has multiple rows, You want the find the value "Vivek", but you don't know where is it present or which column it may be present, just use this VBO and it will give you an output in the below format.

Column Name, rowindex, columnindex

Name, 1,1

Name,4,1

Which translates into the keyword "Vivek" being present in column named as  "Name" and is present in 1st row of 1st column and is also present in 4th row of 1st column

Solution: 

Blue Prism : Find Any Value inside a collection to return row and column Inex - RPA Tools


VBO ATTACHED




------------------------------
Vivek Goel
RPA Architect
Asia/Singapore
+6594554364
https://www.rpatools.com/
------------------------------
1 BEST ANSWER

Helpful Answers

Hi Vivek, 

Nice work, here's a bit of basic code I use as well when indexing in collections, where DT is the Collection to check, valuetofind is the desired value

DT = new DataTable();
DT = new DataTable();
DT.Columns.Add("Column Name");
DT.Columns.Add("RowIndex");DT.Columns.Add("ColumnIndex");
int rowindex=0;
int columnindex=1;
foreach (DataColumn Column in in_DT.Columns)
{
DataRow[] rows = in_DT.Select(Column.ColumnName+" Like '%"+valuetofind+"%'");
if (rows.Length>0)
{ foreach (DataRow row in rows)
{
rowindex = in_DT.Rows.IndexOf(row)+1;
DataRow dr = DT.NewRow(); dr["Column Name"]=Column.ColumnName;
dr["RowIndex"]=rowindex; dr["ColumnIndex"]=columnindex;
DT.Rows.Add(dr);

}
} else {rowindex = 0;
} columnindex=columnindex+1;
}

------------------------------
James McLintock
Process Analyst and Developer
Blue Prism
Europe/London
------------------------------

View answer in original post

1 REPLY 1

Hi Vivek, 

Nice work, here's a bit of basic code I use as well when indexing in collections, where DT is the Collection to check, valuetofind is the desired value

DT = new DataTable();
DT = new DataTable();
DT.Columns.Add("Column Name");
DT.Columns.Add("RowIndex");DT.Columns.Add("ColumnIndex");
int rowindex=0;
int columnindex=1;
foreach (DataColumn Column in in_DT.Columns)
{
DataRow[] rows = in_DT.Select(Column.ColumnName+" Like '%"+valuetofind+"%'");
if (rows.Length>0)
{ foreach (DataRow row in rows)
{
rowindex = in_DT.Rows.IndexOf(row)+1;
DataRow dr = DT.NewRow(); dr["Column Name"]=Column.ColumnName;
dr["RowIndex"]=rowindex; dr["ColumnIndex"]=columnindex;
DT.Rows.Add(dr);

}
} else {rowindex = 0;
} columnindex=columnindex+1;
}

------------------------------
James McLintock
Process Analyst and Developer
Blue Prism
Europe/London
------------------------------