First, FirstN, Last, and LastN functions in PowerApps

Returns a table's first or last set of records.

Description

The First function returns the first record of a table.

The FirstN function returns the first set of records of a table; the second argument specifies the number of records to return.

The Last function returns the last record of a table.

The LastN function returns the last set of records of a table; the second argument specifies the number of records to return.

First and Last return a single record. FirstN and LastN return a table, even if you specify only a single record.

When used with a data source, these functions can't be delegated. Only the first portion of the data source will be retrieved and then the function applied. The result may not represent the complete story. A blue dot will appear at authoring time to remind you of this limitation and to suggest switching to delegable alternatives where possible. For more information, see the delegation overview.

Syntax

First( Table )
Last( Table )

  • Table - Rquired. Table to operate on.

FirstN( Table [, NumberOfRecords ] )
LastN( Table [, NumberOfRecords ] )

  • Table - Required. Table to operate on.
  • NumberOfRecords - Optional. Number of records to return. If you don't specify this argument, the function returns one record.

Examples

This formula returns the first record from a table named Employees:
First(Employees)

This formula returns the last 15 records from a table named Employees:
LastN(Employees, 15)