First, Last and Index Functions in Power Fx
Image Source:
Power Apps
Sep 3, 2023 2:30 PM

First, Last and Index Functions in Power Fx

by HubSite 365 about Craig White

Talks about #lowcode, #formula1, #powerplatform, #empoweringothers, and #digitaldisruption

Citizen DeveloperPower AppsLearning Selection

Recently, the awesome Nathalie Leenders posted this quandary on Twitter and the Index function came to her rescue.

The First, Last, and Index functions in Power Fx are used to retrieve data rows in a table as record values. The Index function can rescue in situations where the Last function might not be as suitable. None of these functions are delegable per Microsoft's guidance. For instance, a collection built for demonstrating these functions might be a list of drinks. To retrieve the first or last row for such a data:Set, Index, First, or Last functions could be used. On the other hand, the Last function could be more useful for data sets with varying number of records because it doesn't need hardcoded values.

  • The Index function would be used like this: Index(colAlcoholicDrinks,1).Value Index(colAlcoholicDrinks,6).Value.
  • Whereas, the First and Last functions like these: First(colAlcoholicDrinks).Value Last(colAlcoholicDrinks).Value.


The Index function truly shines when it comes to getting values between the first and last record. Retrieving the fourth record in a collection could use: FirstN(colAlcoholicDrinks, 4) to get the first 4 records starting from row 1.

Deep Dive into Power Fx Functions

Power Fx empowers data manipulation in many ways not just confined to First, Last, and Index functions. It's incredibly valuable in managing records, especially when dealing with varying sizings of data. The Index function bypasses hardcoded values. However, to choose a suitable function, understanding the nature of your dataset is crucial. Like if you're dealing with data that may vary in size, you might prefer the Last function. For a specified position record, Index is a perfect deal.

Read the full article First, Last and Index Functions in Power Fx

Learn about First, Last and Index Functions in Power Fx

The First, Last and Index functions in Power Fx allow users to retrieve a row in a table of data as a record value. These functions can be used to access values from specific columns or controls, but are not delegable for large data sets. To get the first or last row from a collection/table of data, the First or Last function can be used. The Index function can also be used, but requires hardcoded values to target a specific row. For retrieving values between the first and last record, the Index function is preferred over a combination of Last and FirstN. FirstN requires the user to specify the number of rows from row 1 to iterate through. Once the record is retrieved, values from the specific columns or controls can be accessed.


More links on about First, Last and Index Functions in Power Fx

First, FirstN, Index, Last, and LastN functions in Power Apps
Feb 22, 2023 — The Index function returns a record of a table based on its ordered position in the table. Record numbering begins with 1 so First( table ) ...
How To Use FIRSTN,LASTN And INDEX Formula In ...
Jun 20, 2022 — LastN. The LastN function returns the first set of records of a table; the second argument specifies the number of records to return. Syntax.
PowerApps First, FirstN, Last, and LastN function with ...
Mar 16, 2021 — PowerApps FirstN is a function that helps to return the first set of records of a table whereas the second argument defines the number of ...
How To Use The Power Apps INDEX Function
The Power Apps INDEX function returns a row from a table by specifying the row number. For example, we could get the 2nd row of a table by supplying the table ...
Power Automate String Functions: Substring And IndexOf
The indexOf function finds the index or position of a character within a given string in a case insensitive way. This power automate string function requires ...


Power Fx, Index Function, First Function, Last Function, FirstN Function