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 Apps / Simple Increment Value...
Power Apps
Unanswered

Simple Increment Value in SharePoint List in Power apps

(1) ShareShare
ReportReport
Posted on by 395
I am wanting to increment a simple ID Value in a SharePoint List each time a value is created. Is there a simple way to do thing in power apps formula? Or in Power Automate. If so, how would that be done.
 
This what I would like it to look like:
CAR-01
CAR-02
........
CAR-100
........
Car-1000
 
I also would like the IDs to be unique, so it can't repeat if a value is deleted. 
Categories:
I have the same question (0)
  • Verified answer
    Nandit Profile Picture
    1,568 Moderator on at
    Hi Trout19,
     
    One way to solve this issue is - combining the built-in ID column with "Car-". After creating the new item, get the id of the last item created and patch the CARID column with "CAR-" and the item's ID.
    //Write the following code after your code for creating a new item (Patch / SubmitForm)
    
    Patch(
        SPList,
        First(SortByColumns( SPList,"Created", SortOrder.Descending)),
        {
            CARID: "CAR-" & First(SortByColumns( SPList,"Created", SortOrder.Descending)).ID
                       
        }
    )
     
    If you just want to increment the previous ID. Here's how you can achieve it. You will need to
    1. get the CAR ID of the last item created,
    2. split it by "-" so we can the value at the end
    3. add 1 to it to create the new CAR ID for the new item.
    This doesn't address your second requirement of not repeating values. If you deleted the item "CAR-04", the formula will treat "CAR-03" as the last item and then create "CAR-04" again instead of creating "CAR-05". Please give it a try and see if it helps:
    Patch(
        SPList,
        Defaults(SPList),
        {
            CARID: "CAR-" & Value(
                Last(
                    Split(
                        First(
                            SortByColumns(
                                SPList,
                                "Created",
                                SortOrder.Descending
                            )
                        ).CARID,
                        "-"
                    )
                ).Value
            ) + 1
        }
    )
     
     
    Hope this helps. 
     
    Kind regards, 
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. 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

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard