Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Power Automate Desktop
Answered

maximum index value of a list variable

Like (0) ShareShare
ReportReport
Posted on 4 Oct 2023 17:49:57 by 41

Using the "Read Text from file", I'm storing the contents into a List variable. I simply need to know how many lines the text file contains. Without looping through each index and manually incrementing a LineNum variable, is there a function that would tell me the maximum index value?

 

Many Thanks!

  • MichaelAnnis Profile Picture
    5,721 Super User 2025 Season 1 on 04 Oct 2023 at 20:17:16
    Re: maximum index value of a list variable

    But if you are looking for that to be your loop max, then you want %List.Count - 1% if your %LoopIndex% is being used to reference the row you are looking for in your list. Because the list is a 0 based index, the first item is 0, the second is 1, so on and so forth until the last item is %List.Count - 1%. 

    Then, when you need to call that row in the loop, you say:

     

    %List[LoopIndex]%

    Good luck!

  • treddfw Profile Picture
    41 on 04 Oct 2023 at 18:14:50
    Re: maximum index value of a list variable

    Thank you very much! I was looking too hard for a solution, and yours is perfect! 

  • Verified answer
    Agnius Bartninkas Profile Picture
    10,045 Most Valuable Professional on 04 Oct 2023 at 18:08:25
    Re: maximum index value of a list variable

    If you have a list stored as %List%, you can get the number of items in it as %List.Count%.

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

    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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Automate - Power Automate Desktop

#1
eetuRobo Profile Picture

eetuRobo 108 Super User 2025 Season 1

#2
CU12050101-0 Profile Picture

CU12050101-0 22

#3
Nived_Nambiar Profile Picture

Nived_Nambiar 20 Super User 2025 Season 1

Overall leaderboard
Loading started