cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
seadude
Level 10

ClearCollect last 10 records from Data Source

Hello.

 

What am I missing here? I'm having trouble putting together the syntax to Collect the last 10 records from a data source.

The data source has a unique ID and data columns, but these aren't really queryable in this case. I was thinking something like:

ClearCollect(
    colLast10,
        Filter(dataSource,
            x -y))

But I can't figure out what "x" nor "y" could be. CountRows(dataSource) - 10? Nope, Last(dataSource) - 10? NOpe
... Any ideas?

Thank yoU!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: ClearCollect last 10 records from Data Source

Hi @seadude,

ClearCollect(colLastten,LastN(datasource,10))

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-first-last

If this answers your question please mark it solved.

Super User
Super User

Re: ClearCollect last 10 records from Data Source

Just a tip but for data sources that exceed 2000 or may do so in the future as the items in the data source grow, Use FirstN(Sort(datasource, ID,Descending),10) to avoid delegation problems. This works even with huge datasources.
3 REPLIES 3
Super User
Super User

Re: ClearCollect last 10 records from Data Source

Hi @seadude,

ClearCollect(colLastten,LastN(datasource,10))

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-first-last

If this answers your question please mark it solved.

seadude
Level 10

Re: ClearCollect last 10 records from Data Source

Thank you for sharing. I almost spelled it out in the Post Title! AH!

Super User
Super User

Re: ClearCollect last 10 records from Data Source

Just a tip but for data sources that exceed 2000 or may do so in the future as the items in the data source grow, Use FirstN(Sort(datasource, ID,Descending),10) to avoid delegation problems. This works even with huge datasources.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 95 members 4,139 guests
Please welcome our newest community members: