cancel
Showing results for 
Search instead for 
Did you mean: 
Dr_Lee

Create a dynamically-updating time counter in a list using Power Automate

A common requirement in lists, both in Sharepoint and the new MS Lists, is to create dynamically-updating time counters that keep ticking over without you having to refresh or change the List manually. For instance, I have a Flow that triggers when a certain Sharepoint List item has exceeded two days in age and a few other criteria. While you can create time delays and the like in your Flow, you may wish to reflect the time passed directly in the List. This article describes an easy way to achieve this in Power Automate. Note that this is a specific application of incrementing a variable.

 

Example

Say that you have a Sharepoint List item in which you wish to populate a dynamically-updating 'hours elapsed' column so that a) this can be used in other calculated columns, which must change value when a certain amount of time has passed, and b) anyone viewing the item can see the hours elapsed without having to refresh the item.  

 

The Broad Approach

One rookie error would be to try and use a formula in the list, for example a DATEIF formula or calculating the difference between a TODAY function and the creation date of the item. Unfortunately, these do not update dynamically, i.e. they will only re-calculate when the item is modified. This would not work for the above scenario. Instead, I achieve the dynamically-updating counter by using a Do Until loop in Power Automate with a incremented integer variable, a Update Item action, and a delay:

 

Picture1.png

 

The following sections explain each step.

 

Step 1: Initialize the Integer Variable

Picture2.png

First, initialize an integer variable starting at -1 (this is assuming you want your time to increment by 1, obviously you can alter this). The reason for the -1 is that once you run the flow element (which is effectively at time zero), the Do Until will immediately increment to zero.

 

Step 2: Create the Do Until Loop with Appropriate Settings

Create the Do Until action:

Picture3.png

 

Here, I am wanting the hour counter in the list to increment hourly, and I want it to do so for 29 days (because this is part of an approval flow, and approvals timeout in 30 days, I have chosen to terminate the flow after 29 days without a response to avoid flow failure). Therefore, I first set the Do Until to stop when the counter reaches 695, as 695 hours are just under 29 days. Under limits, I therefore also put 695 as the count (number of times to loop), and the timeout to be 29 days (P29D).

 

Step 3:  In the Do Until, Increment the Variable

Within the Do Until loop, increment the variable (in this case, by 1).

Picture4.png

 

Step 4: Still In The Do Until Loop, Update the List Item with the New Incremented Variable Value

Picture5.png

Update your List item with the latest variable value.

 

Step 5: Still In The Do Until Loop, Delay the Loop

Finally, use a delay action to delay the loop, in this case I delay by an hour so that the counter increments once per hour:

Picture6.png 

 

As noted, the Sharepoint list will automatically update every hour, reflecting the number of hours elapsed. This can obviously be used to reflect other time increments too.  

Comments

Hi, 

How would I go about trying to increment a timer for just one row of the Sharepoint List? I have tested this and it works well but can't figure out what I need to input to get it so just the modified row starts off the timer? 

Thanks

@JamesTarver this precisely does work for only one row of the list - the "update item" portion of the above flow identifies the single list item (row) and only increments for that item (row)  

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/