web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

Collection Issue

(0) ShareShare
ReportReport
Posted on by 145

Hi.  I am trying to bring data into an app.  The data source is 3120 columns of data.  My plan was to turn it into two separate collections then combine it.  I ran into the following problems:

 

1- I'm not sure how to make the record grab dynamic.  Ideally, I'd create a collection for the first 2k entries then do the lastN(datasource,maxID - 2000).  However, with no ID I'm not sure how I'd do this as counta or countrows will just give me a total of 1000.  I think I can get the ID added to the data source resolve this unless someone knows a better way to get an ID number in PowerApps

 

2- It doesn't look like LastN is working correctly.  I used the following code:

ClearCollect(Codex1,'[FIN_GLCodex]');
ClearCollect(Codex2,LastN('[FIN_GLCodex]',1200));
ClearCollect(Codex,Codex1,Codex2);

 

Here is a gallery of both collections in descending order.  The one on the right should go to 88000

 

dyee_0-1603383685808.png

 

 

When I broke it down, the LastN was grabbing the same data as the first list but just going further.  The only time it worked correctly is when I sorted it by a field but when I did that it only collected 3 of the 12 fields.  I have no idea why this is occurring.  Please help!

Categories:
I have the same question (0)
  • dyee Profile Picture
    145 on at

    I think I know the issue.  The data source is only pulling in 2000 records.  Therefore, the lastN and firstN will only be for those 2000 records.  The solution is to add in a filter, I think.  

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @dyee :

    You are right.The point is LastN and FirstN is not delegable.

    The current best solution is to use filter,for example:

     

    ClearCollect(Codex,Filter('[FIN_GLCodex]',Column1="Kind1"));
    Collect(Codex,Filter('[FIN_GLCodex]',Column1="Kind2"));
    Collect(Codex,Filter('[FIN_GLCodex]',Column1="Kind3"));

     

    Note:If ID=XX is used as the condition, the formula will not be able to delegate. It is recommended not to use ID here.

    In addition,I have an other solution:

    ClearCollect(Codex,FirstN(Sort('[FIN_GLCodex]',ID,Ascending),2000));
    Collect(Codex,FirstN(Sort('[FIN_GLCodex]',ID,Descending),1120));

    Use sort to reorder the data source to obtain the head and tail data respectively. So as long as there are no more than 4000 records in your data source, this method can get all the records.

    Best Regards,

    Bof

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard