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 Platform Community / Forums / Power Automate / First Item in For Each...
Power Automate
Answered

First Item in For Each Loop

(0) ShareShare
ReportReport
Posted on by 25

Hello,

 

i have started to test Power Automate Desktop to fill out a web form based on an Excel spreadsheet.

I am trying to receive the data from cell A2 (the first item in the First Name column).

I have tried several syntaxes but none of them worked. You can find attached one of it.

 

I have also tried the following:

%CurrentItem['First Item']%

The flow copied it as text to the website.

 

I would like to understand how is it possible to iterate through a table in Power Automate Desktop.

 

Thank you in advance!

Tamás

Error1.PNG
ExcelData.PNG
DesktopFlow.PNG
I have the same question (0)
  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @tomka50501,

     

    It appears you've established your flow using Power Fx, which is why this error is appearing. Please recreate your flow by disabling Power Fx. Your error should disappear automatically.

    Deenuji_0-1707755911265.png

     

    In case if you want to try in Power Fx way then below is the syntax for the same.

    Deenuji_0-1707756623737.png

    Code Syntax:

    =CurrentItem.'Customer Name'

     

     

    Thanks,

    Deenu

    -----------------------------------------------------------------------------------------------------------------------

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

  • WillSG Profile Picture
    352 Moderator on at

    Hi @tomka50501  I hope you are doing well.

     

    Here below you will find the snipped code that hopefully will help you with the process that you want to automate.

     

    When it comes to a For Each action, the output would be CurrenItem, however this Current item will contain all the information from the first row, then second row and so on.

     

    So to get the First Name you don’t have to use %CurrentItem[First Name]%, you have to use %CurrentItem[0]%

     

    Why Zero? Because zero is the first number from left to right, the assigned value to Zero is the First Name.

     

    See the image below as well for reference.

     

    Here is the snipped code:

     

    SET ExcelFile TO $'''D:\\User\\wsanchez\\Course RPA\\First Item in For Each Loop\\TestData.xlsx'''

    SET Website TO $'''http://enterhungary.gov.hu/eh/register'''

    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: ExcelFile Visible: True ReadOnly: False Instance=> ExcelInstance

    Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: $'''E''' EndRow: 3 ReadAsText: False FirstLineIsHeader: True RangeValue=> ExcelData

    Excel.CloseExcel.Close Instance: ExcelInstance

    LOOP FOREACH CurrentItem IN ExcelData

        Display.ShowMessageDialog.ShowMessage Message: $'''First Name: %CurrentItem[0]%

    Last Name: %CurrentItem[1]%

    Phone: %CurrentItem[2]%

    Birtdate: %CurrentItem[3]%

    Email: %CurrentItem[4]%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed

    END

     

    Please let me know if it works, happy automation!,


    If I have addressed your inquiry successfully, kindly consider marking my response as the preferred solution. If you found my assistance helpful, a 'Thumbs Up' would be greatly appreciated.

     

    Additionally, I offer specialized consultancy and development services leveraging PAD. If you're interested in exploring these services further, feel free to DM me, and we can initiate a discussion.

     

    Kind regards,

     

    Will SG

    Managing Director & Automation Lead

    RAMS CR (Recruitment & Automation)

    LinkedIn Profile

     

    WillSG_Screenshot 2024-02-12 111107.png

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    You can use indexes, starting with 0 or you can use the title row in parenthesis.  

     

    [0] = ['First Name']

     

    You had 'First Item' which doesn't exist.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 791

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 535

Last 30 days Overall leaderboard