How to compare 2 rows in the same column in For Each Row


I have a For Each Row Activity and need to compare 2 rows in the same column, to see if they are the same.

My datatable:
Project User
123 ABC
345 ABC
678 DEF
912 GHI
So if it is the same user, I want to avoid logging off and logging in again. So if row(1) = row(1)+1 -> continue with next row. If false, log off, log in again and then continue with next row.

I am trying to use the “Assign activity” to create row(1)+1 but my syntax is wrong.

Anybody has a solution?



Hi there @Alangager,
If you simply want to return all unique values, based on the “User” row, you can do the following:

Assign - dtYourDataTable = dtYourDataTable.AsEnumerable.GroupBy(Function (drRows) drRows.Item("User")).Select(Function (drGroupedRows) drGroupedRows.First).CopyToDataTable

If this is not what you require, you may need to provide further information regarding what you are looking to achieve.


1 Like

In a For Each row, the row is incremented to the next row through the loop, so row+1 is not needed, unless you use another type of Loop.

To use the For Each method, you will want to store the last value into a variable so you can check if the next value equals the last value. You can do something like this:

ForEach row In dt
- If row(1).ToString.Trim <> tempstring
— Login Sequence
- Process Sequence
- Assign tempstring = row(1).ToString.Trim

So basically you can store the value to a variable at the end of the loop so when it goes to the next item you can compare that value with the last value.

It might also be helpful to know about logic like @Mr_JDavey recommended. Depending on the amount of data you need to process, this is useful for filtering the data you want to process.

EDIT: for logic correction



1 Like

I have attached an workflow based on your requirements check it. (9.4 KB)


Thanks for all the input.

@MahalingPatil this was what I was looking for.


What details you want to append if id repeats?

i need to populate data into schedule template

ScheduleData.xlsx (8.6 KB)
ScheduleTemplate.xlsx (112.4 KB)

ineed read data from schedule data and populate it into Schedule template. schedule template is a form
if same DataAreaID repeats it need to count+1
how to check same DataAreaID