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 Apps / Yearly running number
Power Apps
Answered

Yearly running number

(0) ShareShare
ReportReport
Posted on by 11

Hello,

 

I have a Sharepoint list form which I customised with PowerApps. One field contains a unique ID that is automatically generated, and the format was specified by my users to be YY#### where the first 2 digits are the current year followed by a 4 digit running number (which is sufficient) to keep track of how many items were submitted in that year.

 

My current formula is this: 

 

Right(Year(Today()),2)*10000+Last('MyList').ID+1

 

which gets the job done for this year, but I was wondering what's the best approach to reset the running number to 1 next year?

 

Categories:
  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Kustomize 

     

    This should do it 

     

    Right(Year(Today()),2)*10000+

     

    First( Sort( Filter('MyList',

    StartsWith( UniqueIDColName, Right(Year(Today()),2) ) ),

    ID, Descending )

    ).ID+1

     

     

     

     

  • Kustomize Profile Picture
    11 on at

    Hi @Anonymous,

     

    The formula looks good, I've updated my field for now but I have received these 2 warnings:

     

    Kustomize_0-1639355280106.png

    Kustomize_1-1639355341063.png

    I anticipate around 7000 entries per year for this list, can filter and sort be able to handle such large datasets? From what I have read, including first till make the warning moot. But I wonder if it's limited to 2000 records, how would the formula know that latest item is included in the sort?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Kustomize 

    So, after some digging I found you get this warning because you are using a Number column with StartsWith, see here

     

    https://docs.microsoft.com/en-us/connectors/sharepointonline/#power-apps-delegable-functions-and-operations-for-sharepoint

     

    To get around this you need to create a new UniqueID column of type Text, with the same data.


    I also had to create a variable to convert the first 2 digits of the Year into Text, then use that inside StartsWith.

     

    A way to test that this works is to go 

    File —> Settings —> General and adjust the Data row limit to a value less than the number of records in your current List. You should still get the correct new UniqueID.

     

    Let me know if I need yo explain this further and with code

  • Kustomize Profile Picture
    11 on at

    Yup seems like the warning went away. I'll accept the solution for now though I can only really verify in January whether it'll reset.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Kustomize 

    You could do a test if you like.

     

    - Add a date picker

    - Set the OnChange to a variable eg myDate

    - Select a future date with the date picker eg 20/02/2022

    - where Today() appears in the formula, replace with myDate

    - run your Patch

     

    Should work as expected 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 223

Last 30 days Overall leaderboard