Finding a specific value in each row and for 2 columns and creating a column with a value [Data tables]

Hi everyone

Would appreciate some help.

I have an excel spreadsheet here that I have converted into a data table.

I have added a new column into the data table as “BAU or Backlog”

I want to see if Column L and Column N contains the value “Due” for every row in the data table.

If Column L = “DUE” and Column N = “DUE”, I want the value “Backlog” to be entered into the “BAU or Backlog” Column.

Can someone please advise how I can go about doing this.

At the moment my workflow looks like this

  1. Excel Application Scope
    Read Range - Sheet 1 (output DT1)
  2. Add data column (columnName “BAU or Backlog”, DataTable = dt1)
  3. For each row ( row in dt1)
    Get row item (column L) → into a variable
    Get row item (column N) → into a variable
    If condition variable = due and variable = due

This is where I’m unsure what activity to use to enter a value into the cells

Hi @Sahdique_Caubang

You can assign the value using the assign activity.

If you use for each row activity, you can do assign like this:
Row.Item(“BAU or Backlog”) = “Backlog”

Actually, you don’t need the two Get Row item activities, you can use this for your IF statement instead:
Row.Item(“ColummLName”).ToString = “due” or Row.Item(“ColummNName”).ToString = “due”

1 Like

Thanks for that loginerror, I’ll try your logic.

Out of curiosity, how would I write into a data table, for each row if I had to?

Just the assign?

Yes, you can use For Each Row activity with assign to assign a value to every row (the ‘row’ changes for each row)

To access single values in the DataTable you can use code like that:
yourDataTable.Rows(rowIndexAsInteger).Item(“columnNameAsString”).ToString

Can you advise if Uipath will consider the first 3 headers as column headers?

I’m trying to figure out which column name to use as

“row.Item(“ColumnL”).ToString = “DUE” and row.Item(“ColumnN”).ToString = “DUE””
isn’t recognizing column l

I’ve managed to figure out which column names to use, albeit it’s not preferable but I’m currently getting this error.

just a note i’ve changed the assign to row.Item(“ColumnBAU or Backlog”) on else.

it’s still giving me the same error

edit:

I think I’ve managed to sort it out. Understanding VB.net is my issue apparently ;D

1 Like