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 / Highest Number in a co...
Power Automate
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?

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

    @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.

     

     

     

  • DanielT Profile Picture
    7 on at

    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.

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard