By 2026, the majority of new business applications are being built by people who don’t have “developer” anywhere in their job title. Microsoft Power Platform — now serving over 30 million monthly active users — has made that possible. But even in a world where Power Apps Copilot can suggest formulas automatically, knowing why a formula works is what separates confident builders from frustrated ones. Two functions that every citizen developer should understand early are FirstN and LastN. They’re simple, practical, and appear in nearly every real-world Power Apps project. This guide explains exactly how they work — and how to use them well.
Table of Contents
What Are Power Platform Functions — and Why Do They Matter?
Before diving into the specifics, it helps to understand what functions actually are in the context of Microsoft Power Platform.
Think of functions as ready-made instructions you give to your app. Instead of writing complex logic from scratch, you call a function by name, pass it some information, and it does the work for you. Power Platform uses Power Fx — an open-source formula language that underpins Power Apps and continues to expand across Microsoft 365 tools in 2026. It’s designed to feel familiar if you’ve ever used Excel formulas, which makes it one of the most accessible entry points into app development for non-developers.
Why Functions Are the Gateway to Power Platform Mastery
- Efficiency: Functions automate repetitive data tasks so you don’t have to build logic manually every time.
- Simplicity: Even complex operations — like retrieving the five most recent records from a database — can be expressed in a single line.
- Scalability: As your apps grow, functions like FirstN and LastN help manage performance by limiting how much data your app retrieves at once.
- AI-assisted authoring: In 2026, Power Apps Copilot can suggest FirstN and LastN formulas in context — but understanding what those suggestions mean is still essential. Copilot generates the formula; you need to know whether it’s the right one for your situation.
According to Microsoft’s FY2024 earnings reporting, over 97% of Fortune 500 companies use Power Platform in some capacity, and Power Apps alone has seen 50% year-over-year growth in active makers. Whether you’re building your first app or trying to understand what your organization’s citizen developers are producing, foundational function literacy is no longer optional — it’s a professional skill.
The First and FirstN Functions Explained
What Does the First Function Do?
The First function retrieves exactly one record — the very first item in a table or collection. Think of it like asking, “Who’s at the front of the line?” It returns a single record, not a table.
Syntax:
First(Table)
Example:
First(["New York", "Los Angeles", "Chicago"])
// Output: "New York"
This is useful when you want to display a single value — for example, showing the most recently created support ticket in a status dashboard, or pulling the top result from a sorted list.
What Does the FirstN Function Do?
FirstN extends that logic by letting you specify how many records you want from the top of a table. Instead of one record, you get a slice.
Syntax:
FirstN(Table, NumberOfRecords)
Example:
FirstN(["New York", "Los Angeles", "Chicago", "Houston", "Phoenix"], 3)
// Output: ["New York", "Los Angeles", "Chicago"]
This becomes especially powerful when combined with SortByColumns. For example, if you want to display the five most recently submitted expense reports in a gallery:
FirstN(SortByColumns(ExpenseReports, "SubmittedDate", Descending), 5)
That single line sorts your data by date (newest first) and then returns only the top five records — exactly what you’d want to display in a dashboard widget. It’s the kind of formula that Power Apps Copilot might suggest automatically in 2026, but knowing how to read and adjust it yourself gives you far more control over the result.
When the Count Exceeds Your Table Size
A common beginner question: What happens if I ask for more records than exist?
If your table has only three records and you write FirstN(MyTable, 10), Power Apps simply returns all three records without throwing an error. The function is graceful — it gives you what’s available, up to the number you specified. This makes FirstN safe to use even when your data volume varies.
The Last and LastN Functions Explained
What Does the Last Function Do?
The Last function is the mirror image of First. It retrieves the single last record from a table or collection — the item at the very end of the list.
Syntax:
Last(Table)
Example:
Last(["New York", "Los Angeles", "Chicago"])
// Output: "Chicago"
A practical use case: imagine you’re logging user actions in a collection throughout an app session. Last(UserActionLog) instantly retrieves the most recent action without any additional sorting logic.
What Does the LastN Function Do?
LastN works exactly like FirstN, but from the opposite end of the table. It returns a specified number of records from the bottom of the list.
Syntax:
LastN(Table, NumberOfRecords)
Example:
LastN(["New York", "Los Angeles", "Chicago", "Houston", "Phoenix"], 2)
// Output: ["Houston", "Phoenix"]
A real-world scenario: you’re building an app that tracks inventory adjustments, and you want to show the last three entries in a running log. Rather than loading the entire dataset, you write:
LastN(InventoryLog, 3)
Clean, readable, and efficient.
FirstN vs. LastN: Which Should You Use?
The choice comes down to how your data is ordered and what you want to surface:
- Use FirstN when your data is already sorted with the most relevant records at the top — for example, a SharePoint list sorted by newest date descending.
- Use LastN when the records you care about are at the bottom — for example, an append-only log where the newest entries are added to the end.
- When in doubt, combine either function with SortByColumns to take explicit control of the order before slicing.
Delegation and Performance: What Every Beginner Needs to Know
This is where many new Power Apps builders hit their first wall — and understanding it will save you hours of troubleshooting.

What Is Delegation?
Power Apps has a default data retrieval limit of 500 records (configurable up to 2,000 in app settings). When you connect to a large data source like SharePoint or Dataverse, Power Apps can either:
- Delegate the query to the data source, letting the server handle filtering and sorting before sending results back.
- Retrieve locally, pulling records into the app and processing them on the client side — but only up to the 500–2,000 record cap.
When a function or formula can’t be delegated, Power Apps shows a yellow warning triangle. This means your formula might silently return incomplete results if your data source has more records than the retrieval limit.
Do FirstN and LastN Support Delegation?
According to Microsoft’s official Power Apps documentation, FirstN and LastN are not delegable for most data sources, including SharePoint and Dataverse. This is an important constraint to understand.
What this means in practice:
- Power Apps will retrieve up to the configured record limit (default: 500) from your data source first.
- FirstN or LastN then operates on that local subset — not on the full dataset.
- If your SharePoint list has 5,000 items and you write
FirstN(MyList, 10), you may not actually be getting the first 10 records from the full list. You’re getting the first 10 from the 500 that Power Apps retrieved.
How to Work Around the Delegation Limitation
The most reliable approach is to sort and filter at the data source level before applying FirstN or LastN. Here are the practical strategies:
- Use delegable Sort functions first:
SortByColumnsis delegable for SharePoint and Dataverse, so combining it with FirstN gives you a more predictable result — the sort happens on the server, then FirstN trims the returned set. - Increase your data row limit: In Power Apps settings, you can raise the non-delegable warning threshold to 2,000. This won’t fix delegation, but it increases the local pool FirstN draws from.
- Use Dataverse instead of SharePoint for large datasets: Dataverse offers broader delegation support overall, making it the stronger choice when you’re working with thousands of records. Understanding the differences between Dataverse and SharePoint as data sources is worth the investment early in your Power Platform journey.
- Apply Filter before FirstN: If you can narrow your dataset with a delegable Filter expression first, the remaining records that FirstN operates on will be more representative of your full data.
Understanding delegation is one of the most important foundational concepts in Power Apps. For a deeper dive, Microsoft’s delegation overview documentation is the definitive reference.
Combining FirstN and LastN with Other Power Fx Functions
One of the strengths of Power Fx is composability — functions work together naturally. Here are the most useful combinations for everyday app building.
FirstN + SortByColumns
This is the most common pattern you’ll use in galleries and dashboards:
FirstN(SortByColumns(ProjectTasks, "DueDate", Ascending), 5)
This returns the five tasks with the nearest due dates — a natural fit for a “what’s coming up” widget.
LastN + Filter
Combine LastN with a delegable Filter to narrow your dataset before taking the tail end:
LastN(Filter(SalesOrders, Region = "North America"), 10)
This filters orders by region first, then returns the last 10 from that filtered set.
FirstN + Collect
When you want to store a subset of records for use elsewhere in your app:
Collect(TopCustomers, FirstN(SortByColumns(Customers, "Revenue", Descending), 10))
This creates a local collection called TopCustomers containing the ten highest-revenue customers — useful when you need to reference that data multiple times without re-querying the source.
Nesting with CountRows
Want to know how many records FirstN actually returned? Wrap it:
CountRows(FirstN(MyTable, 20))
This is handy for debugging — especially when you’re checking whether your delegation setup is returning the expected number of records.
FirstN and LastN vs. Filter and Search: Choosing the Right Function
A question that comes up frequently in the Microsoft Power Apps Community: Should I use FirstN, or just Filter? Here’s a practical breakdown.
| Function | What It Does | Best For |
|---|---|---|
| FirstN | Returns the first N records from a table | Limiting display to a fixed number of top records |
| LastN | Returns the last N records from a table | Showing the most recent entries in a log or feed |
| Filter | Returns all records matching a condition | Finding specific records by criteria |
| Search | Returns records where a text column contains a string | User-driven search experiences |
| Sort / SortByColumns | Reorders records | Controlling display order before slicing |
The key insight: FirstN and LastN are about quantity. Filter and Search are about criteria. In most real apps, you’ll use them together — filter to the relevant records, then use FirstN or LastN to limit how many you display.
Frequently Asked Questions
What is the difference between First and FirstN in Power Apps?
First always returns exactly one record — the single first item in a table. FirstN returns a specified number of records from the top of the table. Use First when you need a single value; use FirstN when you need a list of a specific size.
Do FirstN and LastN support delegation with SharePoint or Dataverse? No — as of 2026, FirstN and LastN are not delegable for SharePoint or Dataverse. They operate on the records already retrieved by Power Apps (up to your configured limit of 500–2,000). To get reliable results with large datasets, combine them with delegable Sort or Filter functions, and consider increasing your app’s data row limit in settings.
How do I show only the top 5 results in a Power Apps gallery using FirstN?
Set the gallery’s Items property to a FirstN formula. For example: FirstN(SortByColumns(YourDataSource, "DateColumn", Descending), 5). This sorts your data source by date (newest first) and feeds only the top 5 records into the gallery.
Can I combine FirstN with Sort and Filter in the same formula?
Yes — and this is exactly how most production formulas are written. A typical pattern is: FirstN(Filter(SortByColumns(DataSource, "Column", Ascending), Status = "Active"), 10). Power Fx evaluates from the inside out, so the sort and filter run first, then FirstN trims the result.
Why is my FirstN formula returning unexpected results? The most common cause is a delegation issue. If your data source has more records than your app’s retrieval limit (default: 500), FirstN is only seeing a portion of your data. Check for the yellow delegation warning triangle in the Power Apps editor, increase your data row limit in app settings, and ensure any sorting is done with a delegable function like SortByColumns before applying FirstN.
Start Small, Build Confidently
FirstN and LastN are two of the most immediately useful functions in the Power Fx library — practical on day one, and still relevant as your apps become more sophisticated. The low-code/no-code market is projected to reach $187 billion by 2030, and the professionals who thrive in that environment will be the ones who combine AI-assisted tools with genuine formula literacy. Master these building blocks now, and you’ll have a much stronger foundation for everything that comes next — from working with Sort and SortByColumns in galleries to understanding how delegation affects your entire app architecture. The best time to start is with the next app you open.
References & Read More
Related Wealth Stack guides:
External sources:
1 thought on “Understanding Microsoft Power Platform Functions: A Beginner’s Guide to the FirstN and LastN Functions”