cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

How can I display top 5 latest items from the SharePoint list with Search functionality?

Hello,

 

I have created PowerApps by connecting existing SharePoint list with 200 items.On Browse Screen, it displays items as per following formula:

 

SortByColumns(Filter([@'DataSource'], StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

 

While, I want to display top 5 latest items from SharePoint list with Search functionality ( Meaning, I should be able to find items from the gallery using keyword), I have tried  with LastN(DataSource,5), however it doesn't display the latest items, also how can I achieve the search functionality? 

 

Is there any restriction in gallery to display top 5 latest items?

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: How can I display top 5 latest items from the SharePoint list with Search functionality?

Hi @PowerApper25 ,

The LastN filter depends on the Sort, so your current code will show the last 5 sorted by title - try this on ID

LastN(
   Sort(
      Filter(
         [@'DataSource'], 
         StartsWith(
            Title, 
             TextSearchBox1.Text
         )
      ), 
      ID, 
     Descending
   ),5
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

6 REPLIES 6
Highlighted
Community Champion
Community Champion

Re: How can I display top 5 latest items from the SharePoint list with Search functionality?

Hi @PowerApper25 ,

The LastN filter depends on the Sort, so your current code will show the last 5 sorted by title - try this on ID

LastN(
   Sort(
      Filter(
         [@'DataSource'], 
         StartsWith(
            Title, 
             TextSearchBox1.Text
         )
      ), 
      ID, 
     Descending
   ),5
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Highlighted
Community Champion
Community Champion

Re: How can I display top 5 latest items from the SharePoint list with Search functionality?

First of all with only 200 items, check your delegation limit if its less than 200 by going to setting ...> Advance setting and can be increased up to 2000. 

 

Secondly, if it still does not work, try collection:
      ClearCollect(MyTable,[@'DataSource'])

Then filter with:

      SortByColumns(Filter(MyTable, StartsWith(Title, TextSearchBox1.Text)),
     "Title", If(SortDescending1, Descending, Ascending))

After that you can filter the last 5:
         LastN(MyTable,5)
Note: You can combine the last two formulas if you want to

 

 

Highlighted
Helper II
Helper II

Re: How can I display top 5 latest items from the SharePoint list with Search functionality?

@WarrenBelz 

 

default datarow limit was 500, I have changed as 2000, however formula is not displaying expected results.

 

Formula :

 

 

 

LastN(
   Sort(
      Filter(
         [@'DataSource'], 
         StartsWith(
            Title, 
             TextSearchBox1.Text
         )
      ), 
      ID, 
     Descending
   ),5
)

 

 

Result:

f1.png

 

Formula 2:

 

 

LastN(
   Sort(
      Filter(
         [@'DataSource'], 
         StartsWith(
            Title, 
             TextSearchBox1.Text
         )
      ), 
      ID, 
     Aescending
   ),5
)

 

 

 

Result:

f2.png

 

While Expected Result is:

 

Record - 201

Record - 199

Record - 198

Record - 197

Record - 196

 

What could have gone wrong?

Highlighted
Helper II
Helper II

Re: How can I display top 5 latest items from the SharePoint list with Search functionality?

@eka24 

 

Thank you, unfortunately, It was throwing an error while writing formula one by one to combine them, therefore it did not work for me.

Highlighted
Community Champion
Community Champion

Re: How can I display top 5 latest items from the SharePoint list with Search functionality?

Please Can yo display screenshot of the error?

Highlighted
Resolver II
Resolver II

Re: How can I display top 5 latest items from the SharePoint list with Search functionality?

@PowerApper25 

 

try this and tell me if it works

FirstN(
   Sort(
      Filter(
         [@'DataSource'], 
         StartsWith(
            Title, 
             TextSearchBox1.Text
         )
      ), 
      ID, 
     Descending
   ),5
)

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,787)