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 / Increment integer in a...
Power Automate
Answered

Increment integer in a text file

(0) ShareShare
ReportReport
Posted on by 98

I am using a text file that stores an integer that is being used as a counter.

How would I read that files contents into a variable and then increment the variable by 1 and overwrite the data in the same file ?

Categories:
I have the same question (0)
  • mattias1172 Profile Picture
    on at

    This is possible. Below are the steps if the txt file is stored in SharePoint. 

     

    In short, you need to:

    1. Get the file content of the txt file
    2. Assign to a variable (make sure its of type integer)
    3. Increment the variable by +1
    4. Update the txt file with the new value (of type string due to Power Automate limitation)

    You can convert between integer and string by using the int() and string() expressions. 

     

    Below is the full flow:

    mattias1172_0-1647456474410.png

     

  • dmooreii Profile Picture
    98 on at

    I cannot find any "Counter" action

  • mattias1172 Profile Picture
    on at

    Counter is the custom name given to the action. 

     

    The action's name is "Initialize Variable" followed by an "Increment Variable". 

  • dmooreii Profile Picture
    98 on at

    So that is a set variable action ?

  • mattias1172 Profile Picture
    on at

    It's the initialize variable action. You can't set or increment a variable without first initializing (creating) it. 

    mattias1172_0-1647459481658.png

     

  • dmooreii Profile Picture
    98 on at

    So my get input from file action is buried in my flow and it made me do the initialize variable at the begging of the flow.

    Will that work  if I read and set the variable at the beginning of the flow and increment later in the flow depending depending on a condition ? 

  • Verified answer
    mattias1172 Profile Picture
    on at

    yes, you can initialize on the top level and leave the variable empty. Then later down in the flow, use a set variable action to add the data into the variable followed by the increment variable. 

  • dmooreii Profile Picture
    98 on at

    Worked great. Thank you so much.

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard