Skip to main content

Notifications

Community site session details

Community site session details

Session Id : QjXdSfssa14hQiqL9SLIHE
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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

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

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started