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 / Get the ID of last Ite...
Power Apps
Answered

Get the ID of last Item of Sharepoint and return it to Power Apps

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello everybody!

I want to get the highest/largest ID in a SharePoint library (the most recent item submitted) and return it to PowerApps (in order to use it as a "counter").
Is it possible? I am trying with formulas such as "Max" or "Sort" but every time this error appears:

Sort.PNG

It says that "Delegation problem” because it takes to many items.
I just want the last Item created ID and return it to Power Apps (so I don't need the formula to run through all the lines...).

 

Any solution will be usefull! Thanks!

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    Sort and pick the first:

    Last(Sort(Datasource,Descending)).CreatedID

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Pstork1 Profile Picture
    69,129 Most Valuable Professional on at
    First(Sort(Datasource,ID,Descending)).ID

    @eka24 I think you meant to use this formula

    First(Sort(Datasource,ID,Descending)).ID
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks the answers!

     

    It works but I still have the delegation problem, the same as before (with the yellow triangle), as you can see:

     

    PPP.PNG

     

    Any ideas? 

     

    (For information, 'Non-conformité App is my data source (SharePoint Library))

     

     

  • eka24 Profile Picture
    20,923 on at

    Change it from Last TO First

    First(Sort('Non-conformité App,ID,Desending)).ID

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
  • Pstork1 Profile Picture
    69,129 Most Valuable Professional on at

    The warning is because First() can't be delegated.  But since you are sorting the list in Descending order, which can be delegated, you are assured that the highest Id is the First item in the list.  So it won't matter that First() isn't delegable in this case.  You only need the first item no matter how many there are.

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@Alexx1,

    Based on the issue that you mentioned, do you want to remove the delegation warning?

    Actually, the SharePoint ID field for a table is a number field in PowerApps. However, SharePoint only supports the equal "=" operator for delegation on an ID field.

     

    071301.png

    Best Regards,

    Qi

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks to everybody for the answers!

     

    So I tested with "First" too and the warning still remains as you explained:

     

    rrr.PNG

     

    So are you telling me that it is normal, and that it doesn't matter if there is a warning? And that I will never have any problem with this, even if I have 10000 Items for example in the future?

     

    Thanks! 😉

  • Verified answer
    eka24 Profile Picture
    20,923 on at

    @Anonymous 

    The issue is that Sort in itself is delegable:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview

     

    Sort Descending, turns the Table upside down such that the last item or ID becomes the first,

    So you will not have issues picking the first from the sorted item which will be on top. That is it becomes number 1 no matter long the records.

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • eka24 Profile Picture
    20,923 on at

    The picture below has 7200 records in SQL:

    sort.JPG

     

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yes, but you don't have the little yellow triangle warning in your example! 

     

    I have it, so I'm not 100% confident 😂

     

    But if it works it is ok.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard