I have a lookup data table activity which keeps giving me a row index of -1, surely this can’t be right? Has anyone had this issue before?
Hi @E.T.S ,
Would ask you to investigate the values in the Datatable and the value you have configured as the Look Up.
It could have spaces at the ends and that would lead to not identify the value properly.
Let us know the details after you have checked it out, You could also Debug and check the values supplied to Look Up Datatable
activity.
I’ve managed to accommodate for the spaces - but am still getting the row index as -1
Show us what you have in its properties. We can’t just guess at it.
It appears to be configured correctly. It’s just that whatever value is in strKeyArea is not found in your second column. You know columns are 0 index, so index 1 is the second column, right? It’s much better to use ColumnName instead of ColumnIndex.
I won’t know the name of the column
I’ve added an output data table activity under my read range activity (from where my data table input was coming from)
But still get the error
Unsure how to configure the column name:
Output Data Table isn’t relevant here. If you won’t know the name of the column how can you know which column to look up the value in? You realize Lookup Data Table is looking in just the specified column for the value, not the entire datatable, right?
Inputted the column name but the row index is still coming out as -1 even though what I am looking row exists in the data table
Line 1 are the column names - line 2 is the data but it is a different colour to line 5 → could this be contributing to why it cannot be picked up by the look up activity?
Color has nothing to do with it. That’s just the output display.
What is the value in strKeyArea you’re trying to find? It’s not looking for the value inside the text of a cell, it’s looking for a cell that equals exactly that value. So if the cell has “this is my text” and strKeyArea is “text” it’s not going to find it. It’s not a contains, it’s an equals.
Provide a better example of your datatable. Put a breakpoint on the lookup activity, run in debug, and when it pauses go to the pane on the left, click the pencil icon for dtCorrespondingTab, copy to clipboard, and paste here (then highlight it here and click the </>
icon)
@E.T.S ,
As mentioned by @postwick regarding the column indices, it does seem that you were using the wrong column index. From the Look Up Value variable used (strKeyArea), maybe it is the Key Area column you need, and since it is the First column, so you would have to use index as 0) , could you check by changing the column index to 0
?
Hi @E.T.S
Getting a row index of -1 in a Lookup DataTable activity in UiPath typically indicates that the specified data was not found in the DataTable. This is a common result when using the Lookup DataTable activity, especially when the value you are searching for is not present in the DataTable.
It could be any of these reason-
- Data Mismatch: The value you are looking for in the Lookup DataTable activity might not exactly match the data in the DataTable. Ensure that the data you are searching for is formatted and spelled correctly.
- Case Sensitivity: By default, the Lookup DataTable activity is case-sensitive. If your search data and the data in the DataTable have different cases (e.g., “John” vs. “john”), it won’t find a match. You can use the
StringComparer.OrdinalIgnoreCase
option to perform a case-insensitive lookup.
Thanks!
The row index is still -1 when column index is 0 unfortunately
data table:
Noticed this ‘End of statement expected.’ message when hovering over the data table
As we have said multiple times, columns are 0 index so the first column is 0 not 1. You have 1 in your Lookup, so it’s looking at the Issue column, not the Key Areas column.
Show us what’s in the datatable. Your screenshot isn’t useful.
Provide a better example of your datatable. Put a breakpoint on the lookup activity, run in debug, and when it pauses go to the pane on the left, click the pencil icon for dtCorrespondingTab, copy to clipboard, and paste here (then highlight it here and click the
</>
icon)
[Key Areas ,Issue ,Potential Exposure,Recommendations
Directors’ remuneration:
Engaged via a Personal Service Company (PSC)
,"other data here
Please follow my specific instructions. What you keep posting isn’t helpful.
Apologies - I am unsure what you mean by (then highlight it here and click the </>
icon)