Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Highest Number in a column

(0) ShareShare
ReportReport
Posted on by 7

Hi,

So I'm hoping someone can help me. I am trying to create a project number generator. So basically in SharePoint, a user would fill out the New form and it will generate a number for you based on the what the next highest number is. I have found a few tutorials and I can get it the number to increment based on the ID. However, this does not solve the problem where someone creates a number then deletes the row. This will lead to it skipping a number the next time an item is created.

Is there a way to calculate the highest number in a column and add 1? Can I loop through each row if needed to find the highest number?

  • DanielT Profile Picture
    7 on at
    Re: Highest Number in a column

    Hi Scott,

    Thanks for your help. I finally was able to achieve what I wanted used the Get items function you recommended. I sorted "Current_Numb desc" and set Top Count to 1. Then using the Update Item function, I set Current_Numb to

    add(first(body('Get_items')?['Value'])?['Current_Numb'],1). This made it so I can delete with no problems and the sequence will remain in tact.
     
    Thanks again for the help.
  • Verified answer
    ScottShearer Profile Picture
    25,208 Most Valuable Professional on at
    Re: Highest Number in a column

    @DanielT 

    One way to approach this is to use a Get items action.  Configure it to return just one item and sort in descending order on your column.  That value will be the highest number now in that column.

    In my example, I reference the ID, but you could reference any numeric column.  You might want to create a variable and stuff the value in a variable.

     

    MaxNumber.jpg

     

    Alternatively, you could maintain a second list with one entry that just stores the last number used.  When you need a new number (next number), you can reference the list and then update it by incrementing the number by one.

     

    If you have a high volume of transactions, norther of these are a great idea as it could generate duplicates.  However, they will work if it you don't have a high volume of transactions.

     

     

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,605 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,946 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow