cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
charles_ross_oh
Advocate I
Advocate I

Power Automate Desktop - loaded CSV to Dataset, For each - CurrentItem - is there a Row Number property?

I have loaded a CSV file using "Read from CSV file" and this produces the variable "CSVTable" which is a Datatable. Then I am going thru the items in the data table with a "For each" loop , which places each row from "CSVTable" in the variable "CurrentItem". 

 

Is there some internal variable (something like "CurrentRow") that can tell me the Data table row number property of "CurrentItem"? 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
tkuehara
Solution Specialist
Solution Specialist

Hi @charles_ross_oh 

 

There's no "current row index" property when running a for each loop. You need to create a variable and increase it manually.

tkuehara_0-1630420432348.png

Or, alternatively, rewrite the code to run a simple loop and therefore you'll have the built-in index variable in it as suggested by @MichaelAnnis. Please notice though that the loop index might not match with your data source (in the example above, an Excel file) row, so you'll still need to adjust it according to your needs.

View solution in original post

4 REPLIES 4
MichaelAnnis
Impactful Individual
Impactful Individual

Make sure you tell "Read from CSV file" if the first row is titles, so the first row [0] is actual data.  The syntax for getting a specific data sets is %CSVTable[Row][Column]%.  So, if you wanted the 3rd column from the first row, just remember that they both start with 0, so it would be %CSVDataTable[0,2]%.

 

For something like, for each row, do XYZ, I would use a loop instead of For Each:

 

Loop Starting at 0 ending at %CSVTable.RowsCount% increment by 1.

Then you can say %CSVTable[LoopIndex][2]% to get the 3rd column of the row indicated by the LoopIndex.

 

Good luck.

 

 

These are good tips, thanks. However those are not answers to the question I posted., which is for a current row property.

You asked for a way to get through each row with a variable that could be used for a row index.  I gave you an example of how to do a Loop where %LoopIndex% is the row variable.

tkuehara
Solution Specialist
Solution Specialist

Hi @charles_ross_oh 

 

There's no "current row index" property when running a for each loop. You need to create a variable and increase it manually.

tkuehara_0-1630420432348.png

Or, alternatively, rewrite the code to run a simple loop and therefore you'll have the built-in index variable in it as suggested by @MichaelAnnis. Please notice though that the loop index might not match with your data source (in the example above, an Excel file) row, so you'll still need to adjust it according to your needs.

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,025)