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 / Problem using LAST fun...
Power Apps
Unanswered

Problem using LAST function to generate unique ref no

(0) ShareShare
ReportReport
Posted on by 49

I have successfully been using the LAST function to generate a unique ref number for my sharepoint list. Formula as following

If(SharePointForm1.Mode = New,Text(Last(ContractsNew.ID).ID + 70001),Parent.Default)

I struck a problem when my list exceeded 500 items. 

My Unique ref Number no longer reflected the last ID but got stuck on 70501 … As if LAST has a limitation of 500 items.

Has anyone struck this issue and is there a workaround?

Categories:
I have the same question (0)
  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at

    How are you populating ContractsNew, in other words, is it populated directly from the data source? Have you tried populating that in a collection and then using it in the LAST function? 

  • Verified answer
    PaulD1 Profile Picture
    2,914 on at

    You are hitting the infamous delegation limits. SP is sending back the first 500 items from your list and then PA is grabbing the last one, so once you have 500 records your ID will never increment.

    You can go into Settings and change the limit (up to 2000) though this is just kicking the can down the road and not addressing the poor performance that results from SP sending lots of records to PA when you only need 1.

    Try wrapping your ContractsNew in a SortByColumns and sort by ID descending and get the First rather than the Last item.

    The sort should be delegable and occur in SharePoint and the connector should be able to fetch just the one (first) record.

  • Community Power Platform Member Profile Picture
    on at

    Have you set the data row limit in your app to 2000? Default is 500 so maybe that is why?

    File --> Settings --> enter 2000 in data row value field

     

    If you are referencing straight from a SP list, try putting this into a label to see/get the LAST ID:

     

    First(SortByColumns(yourSPList, "ID", Descending)).ID

     

    EDIT: what @PaulD1 said, he beat me too it lol

  • jb007 Profile Picture
    49 on at

    Thanks Eelman … Its all logical when the solution is presented

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