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 a variable e...
Power Automate
Answered

Increment a variable each time an automated flow is run

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm making a flow that saves each new email attachment that comes into a shared mailbox by a new name in sharepoint that includes a number that increases by 1 each time a new file is created. I'm looking for a suggestion on how to do this. I was originally going to get a number from a cell in an excel table, add it to the file name, and then increment it up one and update the excel cell with the new number but I can't figure out how to do that. Thanks!

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @Anonymous 

    There are a few ways to go about this.  Since you're already using SharePoint, why not just create a custom SharePoint list.  Add a number column to the list - call it something like NextNumber.  The list will only have one row of data.  Use a SharePoint Get Items action to retrieve that row and the number.  Then, update the SharePoint list incrementing the number by 1.  Using a SharePoint list will allow you to avoid issues that sometimes take place when updating Excel files.

    As I said, there are a number of ways to go about this...

    If you need an example, please let me know.

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @ScottShearer 

     

    Could you provide an example? I am having trouble capturing the number in the list as a dynamic value so I can initialize a variable.

  • Verified answer
    ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @Anonymous 

    See my example below.  You can refer to the variable when renaming the file.  I could have made this a bit more elegant with the use of expressions, but I tried to keep it as simple as possible.

    OneUp1.jpgOneUp2.jpgOneUp3.jpg

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Perfect Thanks 🙂

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!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 283

#2
David_MA Profile Picture

David_MA 256 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard