FirstN(Source, NumberOfRecords)
- Source: The table or collection from which you want to retrieve records.
- NumberOfRecords: Optional. The number of records you want to retrieve from the start of the source. If you do not specify this argument, the function returns one record from starting.
Usages of FirstN function
Displaying the First N records in a Gallery
You can use the FirstN function to show only the first n records in a gallery.
As you can see, the gallery is displaying records from the collection named colEmpData, with a total of 7 records shown

Let’s use the FirstN function to display the first 3 records from the collection colEmpData in a gallery.
Go to the Item property of Gallery and write below formula.
FirstN( Â colEmpData, Â 3 )
The formula looks at the colEmpData collection and retrieves the first 3 records based on the order of records in the collection.
You can see, the gallery displays the first 3 records from the collection.

Note if you do not provide the second argument NumberOfRecords value in the FirstN function, it will return first one record from table/collection.
As you can see in the formula below, we did not specify the number of records to be returned from the collection in the FirstN function, which results in it returning only the first one record from the collection
FirstN(colEmpData )

Fetching the First N records from a Table
If you only want to get the first records from a table, you can use FirstN with 3 as the number of records.
FirstN(Employees, 3)
This formula returns the first 3 records from the Employeestable.
When to use FirstN function
- You can use FirstN function whenever you need to retrieve a specific number of records from the beginning of a collection or data source to improve usability and performance in your app.
- If you want to display top-performing records (e.g. top 10 sales), you can use FirstN to get those records based on a sort order applied to your data.
Read Also..
![]()
