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 / Can you reference vari...
Power Automate
Unanswered

Can you reference variables inside of list index?

(1) ShareShare
ReportReport
Posted on by 31

I have a list of text that I want to loop through and reference the index of my list plus 1 because I want the next line. I can elaborate more on what the goal of the loop is but my question - can I reference a variable inside of an index, if so how? powerAuto.png

Parameter 'Add item': Syntax error.

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Yes.  First, in your Loop, use %TextList.Count - 1% because it's 0 based, so your if .Count = 10, your last item is [9].

     

    You have the AddItemtoList almost correct.  Within a variable, you don't need % signs, so:

    %TextList[IndexPlus1]%

    Good luck!

     

  • tgut03 Profile Picture
    31 on at

    I updated the actions, and the flow is looping through TextList, but for some reason no items are being added to the CatalogNums list. When I look at the textList variable it shows items with a length of ten characters. powerAuto.png

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @tgut03 

     

    Please try the below approach:

    Deenuji_0-1720792781451.png

     

     

    Code(copy and paste the below code into your power automate desktop):

    SET File TO $'''C:\\Users\\Downloads\\output.pdf'''
    Pdf.ExtractTextFromPDF.ExtractText PDFFile: File DetectLayout: False ExtractedText=> pdf
    Text.SplitText.Split Text: pdf StandardDelimiter: Text.StandardDelimiter.NewLine DelimiterTimes: 1 Result=> TextList
    Variables.CreateNewList List=> CatalogNums
    SET Counter TO 0
    LOOP FOREACH CurrentItem IN TextList
     # Check currenitem length is equal to 10 then it will add next list element into catalognums list
     IF CurrentItem.Length > 10 THEN
     # Access next item and store into list
     Variables.AddItemToList Item: TextList[Counter + 1] List: CatalogNums
     END
     SET Counter TO Counter + 1
    END

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Power Automate Desktop Community Champion 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀 

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

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 231 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 217 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 170

Last 30 days Overall leaderboard