Logic for datatable

A datatable

In that “Lastnumber” is the value which is getting by adding +1 with the next row “Number”
Here I am getting each row in datatble using add data row …

Help with the logic

@Sweety_Girl What about the value for the Lastnumber in the last row?

1 Like

DO you need to populate only LastNumber? Name and Number exists in Excel/Datatable? Why exactly you are using AddRow?

1 Like

Hi @Sweety_Girl

“Here I am getting each row in data table using add data row …”

If this is the case, either you’re adding rows with just the “Number” column values and no “Lastnumber” values, or every time your loop runs (assuming there’s some kind of loop involved here), you can find out what the next value in the Number column will be.

If it is the latter, in your add data row property “ArrayRow”, enter – {45 (number value), 72(next number value) + 1}

Enclose the above in an If activity. The condition is that the above “Add data row” only runs if you’re NOT at the last loop. If you are, then for that, you need to have an Add data row activity in the else part as well and in its property–“ArrayRow”–you need to enter this–{78,“”} where “” is an empty string.


1 Like

You can follow below steps:

  1. First find the value from datatable that particular column value by using " Datarow[ ] results = Datatable.Select(“[ColC]=‘your value’”)
  2. The above step will return “ Datarow[ ]
  3. Iterate with Datarow[ ] by using For-each activity with Type Argument = System.Data.Datarow .
  4. Well assuming you have distinct records with values then just find the row index
    " Int value_row_index =yourdatatable.Rows.Indexof(results(0))
  5. Then you can get Next Row’s Column value like this
    String next_col_value = yourdatatable.Rows((value_row_index+1))(“your_col_name”)
  6. now perform your comparison steps with above results.

test.xaml (15.3 KB)

1 Like


Let us take you are having a datatable dta which is having columns Name and Number with Values and Column Lastnumber without Value.

So use below Query in Assign Activity to get the OutPut.

dta= (From p In dta.Select
Let x=If(Not dta.Rows.IndexOf(p)=dta.Rows.Count-1,Convert.ToString(Convert.ToInt32(dta.Rows(dta.Rows.IndexOf(p)+1)("Number"))+1),String.Empty)
Select dta.Clone.Rows.Add(Convert.ToString(p("Name")),Convert.ToString(p("Number")),x.ToString)).ToArray().CopyToDataTable

Now write dta in Excel.


1 Like

LastNumber value is +1 value inthe 2nd row of “Number”

overload resolution failed


I have already tested the query. It’s working fine…

Can you please post the screen shot with query what you have used.


1 Like


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.