web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Answered

Loop Index is Invalid

(0) ShareShare
ReportReport
Posted on by 39

I seem to be having this issue for the past few days. I was asked by my mentor to create a workflow that could be used for retrieving currency exchange values from a website and write them down in Excel. I used a Loop, but I was advised to use a For Each action instead. 

 

However, I seem to be encountering this error, wherein the CurrentItem in For Each is declared invalid whenever I try to execute the workflow. 

 

I keep getting this in the error: Correlation Id: 28932dba-2fa8-4602-90d1-c2f748017aa5

 

Following screenshots have been provided for reference.

 

Any tips and advice will be highly appreciated. 

flow 2.png
flow 3.png
flow 1.png
I have the same question (0)
  • Verified answer
    opit Profile Picture
    162 on at

    @aSagCoder 

    opit_0-1705260450857.png

     

    you need to use: %currentItem[colum name or number]% and then you get value automatically

  • aSagCoder Profile Picture
    39 on at

    That actually worked! Thank you so much for the help! ❤️

  • aSagCoder Profile Picture
    39 on at

    Hi, sorry to bother you again - but the Write to Excel function is not working and using CurrentItem doesn't working as this action requires a number. How can I fix it?

  • opit Profile Picture
    162 on at

    the action write to excel has nothing to do with CurrentItem. It writes to excel values got of element on web page.

    see bellow yellow:

    opit_0-1705347374167.png

     

    you need to specify more detail your problem?

  • aSagCoder Profile Picture
    39 on at

    Yeah, but I actually want to write the numResultList in a specified column range - however, what I used for it isn't working anymore. 

     

    aSagCoder_0-1705395721572.png

    Initially I was using CurrentItem but that was invalid, as Row required a numerical value. So I tried using FirstFreeRow - but that doesn't seem to be working either. 

     

    This is the Excel worksheet I am using, and I wish to write the result extracted in the D column. What can I do in the Write to Excel action to fix this issue?

    aSagCoder_1-1705395816899.png

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    %FirstFreeRow% is a thing that makes sense when you want to append new rows to a table. But you want to write data to existing rows, so that won't work.

     

    Instead, you will need to implement a loop index. Use Set variable before your loop and set an index to 2 (that's the row where your data starts). Then use that variable as the row index in Write to Excel worksheet. And then use Increase variable at the end of the loop to increase it by 1.

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • aSagCoder Profile Picture
    39 on at

    Thanks for this! This works, for the most part. I just encountered a tiny issue - when I tried to implement the new variable for the existing rows, it repeats for the last row and then, adds an additional value to the Excel worksheet. Can you help me figure out why it is doing so and how can I fix it?

    aSagCoder_0-1705400130628.png

    Here's the workflow for reference - 

    aSagCoder_1-1705400270467.png

     

    I tried using %nbrrowindex - 1%, but this causes it to overwrite the column header with the extracted numeric value instead. How can I avoid that?

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    I would assume this might be because your Read from Excel worksheet probably includes the one last row at the end, too. It might for some reason "think" it's not empty - maybe it had data previously and has some formatting stored there, that has not been cleared properly. Try deleting the row from Excel completely and then run it to see if this helps. Otherwise, add an If statement inside your loop to check if %CurrentITem['Value']% is empty. If it is, use Next loop to skip further actions for this row, or Exit loop to stop looping.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 167

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard