web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Increment integer in a...
Power Automate
Unanswered

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
    385 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
    385 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
    385 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
    385 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard