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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Pull the top 100 items...
Power Apps
Answered

Pull the top 100 items into a collection

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am trying to get around delegation by using a collection.

When the user comes into my app I only want them to see their items and only allow them to modify what they entered "today".

 

My first attempt was in the items of the browse gallery:  Delegation Bad 😞

SortByColumns(Filter([@'Entry'], StartsWith(Title, TextSearchBox1.Text),'Created By'.DisplayName = CurrentUser,Created >= Today()), "Created", If(SortDescending1, Descending, Ascending))

 

I tried to use a collection to get around delegation, but User() gives me one too... Delegation Bad 😞

ClearCollect(MySuff, {LocNum:LookUp('Entry', 'Created By'.DisplayName = User().FullName).'Stuff Number'})

 

I thought I might be able to just pull the top 10 or even 100 from the list for that user, but can't figure that out.

 

Any help with this would be greatly appreciated.  

I would hate to have to import the list items into SQL, and delete the list when it gets to 2000...

 

TIA,

Joe

 

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    on at

    You can avoid the delegation issue with the User() function by saving the value in a variable in the app. If you have this expression in the App's OnStart property:

    Set(userName, User().FullName)

    You should be able to use it in an expression without running into delegation issues:

    ClearCollect(MySuff, {LocNum:LookUp('Entry', 'Created By'.DisplayName = userName).'Stuff Number'})

    Hope this helps!

  • v-xida-msft Profile Picture
    on at

    Hi @joef ,

    How many records stored in your 'Entry' data source? More than 2000?

    Is the 'Entry' data source a SP List?

     

    Regarding the needs that you mentioned, I think a global variable could achieve your needs. I agree with @CarlosFigueira 's thought almost. You could consider store the User().Email result into a variable, then you could compare the 'Created By'.Email with this variable value.

     

    I assume that your 'Entry' data source is a SP List, currently, within SP List, the Date type column is not delegable in Filter functions. Please check the following article for more details:

    https://docs.microsoft.com/en-us/connectors/sharepointonline/#power-apps-delegable-functions-and-operations-for-sharepoint

     

    If your data source list records is not more than 2000, you could ignore this Delegation warning issue. Please set the "Data row limit for Non-delegable queries" option within Advanceds settings of App settings of your app to maximum value -- 2000, then you could process 2000 records locally at most in your app.

     

    If you want to get rid of this Delegation message, I think the Collection could achieve your needs. Please set the OnStart property of App to following:

    ClearCollect(RecordsCollection, [@'Entry']);
    Set(CurrentUserEmail, User().Email)

    Set the Items property of the Gallery to following:

    SortByColumns(
     Filter(
     RecordsCollection, // Use Collection as data source here 
     StartsWith(Title, TextSearchBox1.Text),
     'Created By'.Email = CurrentUserEmail,
     Created >= Today()
     ), 
     "Created", 
     If(SortDescending1, Descending, Ascending)
    )

    Please consider re-load your canvas app, then check if the issue is solved.

     

    If your data source records is more than 2000, please check and see if the following video resource could help in your scenario:

    https://www.youtube.com/watch?v=2M0zCyu__20

    https://rezadorrani.com/index.php/2019/09/18/powerapps-delegation-with-sharepoint-as-a-data-source-with-respect-to-all-column-types/#respond

     

    Regards,

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard