LastN

LastN

How to Use the Power Fx LastN  Function in Power Apps

What is the LastN Function?

The LastN function is a Power Fx function that is used to retrieve the last N records from a data source. The LastN function takes two parameters, the data source and the number of records to retrieve. The syntax of the LastN function is as follows:


LastN(DataSource, NumberOfRecords)


How to Use the LastN Function

To use the LastN function in Power Apps, follow these steps:

1. Open the app that you want to use the LastN function in.

2. Click on the control that you want to use the LastN function with.

3. In the formula bar, type the following formula:


LastN(DataSource,NumberOfRecords)


4. Replace DataSource with the name of the data source that you want to retrieve data from.

5. Replace NumberOfRecords with the number of records that you want to retrieve.

For example, if you want to retrieve the last 10 records from a SharePoint list called “Products”, you would use the following formula:


LastN('Products', 10)


Example Usage

Let’s say you have a SharePoint list that contains all the orders placed by your customers. You want to create a Power App that displays the last 5 orders that were placed. To achieve this, you would follow these steps:

1. Open the Power App that you want to create the display in.

2. Add a gallery control to the app.

3. In the formula bar, type the following formula:


LastN('Orders', 5)


4. Replace ‘Orders’ with the name of the SharePoint list that contains the orders.

The LastN function is a powerful tool that can help you retrieve the most recent records from your data source. By using this function, you can create custom applications that are tailored to your specific business requirements. If you are new to Power Apps, the LastN function is a great place to start.

Power Apps Training Courses by G Com Solutions (0800 998 9248)