How to get the row number of the row being processed from an datatable

I have been working on a data table where i have been processing through some specific rows, I am trying to get the row no from the column , Need Suggestion on how to get that .

Input Data

Column1

Date1
Date2
Date3
Date4
Date5

I am looking to get the row number for Date4 that is 4.
How i can perform this activity.

Hi

If you are trying to get the row number within a FOR EACH ROW activity while processing each row one by one

Then use this expression in a assign activity like this

int_indexnumber = dt.Rows.IndexOf(row)

This will give the rowindex where 0 is for first row

Or you can get the same from FOR EACH ROW activity itself with its output property

  • Index - A zero-based index that specifies what element of the current collection is being iterated, stored in an Int32 variable.

If you want row number
Then expression will be

int_rownumber = dt.Rows.IndexOf(row)+1

This will give 1 if it’s first row
2 if it’s second row

Cheers @mayankjha986

1 Like

Hi,

There is an output property of the For Each Row activity giving you the current index (zero based) of the processed row as int32!

Just create/assign an integer variable to the property and use it within the For Each Row body.

Don’t forget to add 1 to account for the RowIndex starting with 0.

Thank You @Palaniyappan

I dont have any fixed row value where i can use +1 or +2

I have appended the Excel data into an argument dt_argument

Is it possible to get the row number dynamically as row Rows.IndexOf(dt_argument(“Column1”))

Pleas

May I know what input you have so that I can tell you the way to get its row index

And the one you have share

Rows.IndexOf will take Datarow as its argument
With which it will try to get the row index of that Datarow in that datatable

A datatable is made of datarows

If there are 10 records In datatable then those 10 rows are called as datarows

Cheers @mayankjha986

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