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 / Update Sharepoint list...
Power Automate
Answered

Update Sharepoint list Rank column when an item's ranking is changed

(0) ShareShare
ReportReport
Posted on by 23

I have a SharePoint list that is essentially a ToDo list tracking all of the assignments that come in from the business (chose Sharepoint because it was more flexible/customizable).  The list is accessed on a daily basis by leadership to rank priorities.  The priorities are integer values and sometimes the team lists up to 20 or 30 priorities.  If they change #15 to #1 then they need to go back and fix the rankings of the first 14, which doesn't happen often.  Ultimately what ends up happening to avoid renumbering is we get priority 1.1, 1.7, 5, 5.1, etc.  

 

I am looking for a way to automate the renumbering process and make it so the priorities are 0 decimal point #s.  I thought about trying to add a formula to the Priority field, but wasn't sure what it would be or how it would force the unique values.  So, I started a power automate workflow that kicks off at the end of the day and adds the rank value to an array for the items created/modified that day, but I am stuck on how to compare the array to the list rankings and adjust them accordingly. Any thoughts on how to create that loop (or a better way to force unique, auto-incrementing numbers in sharepoint) is appreciated!

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

    First, set the number column to have no decimals.

    What do you want to happen when a number has changed?  Can you detail the rules?  If I change a number from 10 to 15, what should happen?  If you can explain the rules, then you can create the loop.

     

  • jpenndcl1 Profile Picture
    23 on at

    Great idea - eliminating decimals now.

     

    Let's go with a list of 5 for now...

     

    Initial ValueModified ValueAuto-Incremented Value
    114
    225
    322
    433
    511

     

    So I guess the brute-force way I think of it is to look at the first changed list item priority value, compare it to every other list item's priority value, if the changed priority is greater than the unchanged then unchanged stays the same, if the changed is less than or equal to the unchanged then you increment the unchanged list item priority value by 1 and repeat the process for the remaining changed list item priority values. 

     

    I suspect there is a more elegant way to do this than loading the changed priority item ID into an array and creating a do-while loop to cycle through the array through the array

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

    @jpenndcl1 

    I can't think of any other way...  Even if there were, you have just a small number of items.

     

     

  • ksjones1 Profile Picture
    5 on at

    Hi,

    I am running into the same issue. Would you mind giving me an example of how you did this? Did you write a column validation? 

    Thanks!

  • jpenndcl1 Profile Picture
    23 on at

    Haven't solved it quite yet.  I think I am overcomplicating it by adding arrays and loops and everything...

     

    What if, after the workflow is triggered, I did the following:

    1. used a get items action with
      1. an odata filter that removed all non-ranked items, and
      2. a 2-level sort filter that sorted on rank and then on modified time (ascending for both)
    2. initialized a Count variable to track the number of times I looped as I work through the list (essentially set the rank using the number items)
    3. used an apply to each activity with an update item activity that essentially set the rank based on the count.

    My thinking is that if I sort the items in the order they should appear, then all I need to do is # them accordingly.  I'll let you know if that works...

  • Verified answer
    jpenndcl1 Profile Picture
    23 on at

    Looks like it is working! 

      

    So, in summary:

    1. A recurring trigger for 1x per hour
    2. Initialized a count variable as an integer and set its value at 1
    3. Get items action with the following odata filter/order syntax
      1. "Order By" - "Rank asc, Modified asc"
      2. "Filter Query" - "Rank ne null"
    4. Apply to each loop with Update Item action where the Rank field is set using the Count variable
    5. Increment variable by 1 in the loop to make sure the Rank field increases

    Hope that helps and let me know if you see an error or an issue this isn't addressing!

  • ksjones1 Profile Picture
    5 on at

    Thank you! I will try it out.

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
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 820

#3
Haque Profile Picture

Haque 505

Last 30 days Overall leaderboard