#PowerPlatformTip 107: 'Last Item from SharePointList'
TL;DR: Get the newest SharePoint item in Power Apps with
First(SortByColumns(List, "ID", Descending)), delegable, unlikeLast().
💡 Challenge
You need the latest entry from a SharePoint list in PowerApps, but Last() isn’t delegable, so the direct approach seems out of reach on larger lists.
✅ Solution
Sort the SharePoint list by the ID column in descending order, then take the top row with First(). Both are delegable to SharePoint, so it scales.
🔧 How It’s Done
🔸 Sort the data source by the ID column in descending order so the newest item is on top:
🔸 SortByColumns('Your List', "ID", Descending)
🔸 Wrap it in First() to grab that top item, the latest entry:
🔸 First(SortByColumns('Your List', "ID", Descending))
🎉 Result
You reliably access the most recent item from your SharePoint list in PowerApps, sidestepping the delegation limitation of Last().
🌟 Key Advantages
🔸 Simple & efficient: a straightforward way to get the most recent entry.
🔸 Versatile: sort by other columns (Created, Modified…) for different scenarios.
🔸 Delegable: works on large lists because sorting happens on the server.
🔢 Not Only the Last: the n-th Item
All results below come from a five-row table t with ID 1 to 5 and Title a to e.
🔸 Third item by position: Index(t, 3) returns {ID:3, Title:"c"}. Last(FirstN(t, 3)) returns the same record.
🔸 Second newest: Index(SortByColumns(t, "ID", SortOrder.Descending), 2) returns {ID:4, Title:"d"}, as does Last(FirstN(SortByColumns(t, "ID", SortOrder.Descending), 2)).
🔸 Newest two as a table: FirstN(SortByColumns(t, "ID", SortOrder.Descending), 2) returns ID 5 and ID 4 in that order.
🔸 Out of range: Index(t, 6) and Index(t, 0) return the error Argument out of range. Last(FirstN(t, 6)) does not error and returns the last existing row (ID 5).
🔸 Highest ID as a number: Max(t, ID) returns 5. LookUp(t, ID = Max(t, ID)) returns the full record {ID:5, Title:"e"}.
On a Dataverse table the same formulas behave the same way: Index(Filter(Accounts, StartsWith('Account Number', "ZZ-")), 3) returned the third filtered account, First(SortByColumns(..., "createdon", SortOrder.Descending)) the most recently created one.
🎥 Video Tutorial
🛠️ FAQ
1. Why can’t I use the Last function directly on SharePoint lists? Last() is not delegable for SharePoint in PowerApps, so it only works on the first 500 (or up to 2000) records. First(SortByColumns(...)) returns the actual latest item regardless of list size.
2. Can I sort by columns other than ID? Yes, sort by any orderable column such as Created, Modified, or a custom date/number field, e.g. First(SortByColumns(YourList, "Created", Descending)).
3. Will this method work with large SharePoint lists? Yes. The approach is delegable, so it works efficiently even on lists with thousands of items because sorting and filtering happen on the SharePoint server.
4. How do I select the third item instead of the last one? Index(List, 3) or Last(FirstN(List, 3)). Both returned the identical record in the test. For “third newest”, sort first: Index(SortByColumns(List, "ID", SortOrder.Descending), 3).
5. Can I use Max(List, ID) instead? Max(List, ID) returns only the number (5 in the test). To get the record, wrap it: LookUp(List, ID = Max(List, ID)).
6. What happens if the position does not exist? Index(List, 6) on a five-row table returns the error Argument out of range, so check CountRows() first. Last(FirstN(List, 6)) simply returns the last existing row.
🔗 Related Tips
🔸 #PowerPlatformTip 95: ‘Optimized SharePoint Queries’ - more delegable, server-side filtering patterns for the same kind of large lists.
🔸 #PowerPlatformTip 97: ‘Enhanced Pagination’ - retrieve more than the default item cap once a single sorted record isn’t enough.
This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).