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 Platform Community / Forums / Power Apps / Create gallery from la...
Power Apps
Answered

Create gallery from large sharePoint lists using filters

(0) ShareShare
ReportReport
Posted on by 6

Hello Powerapps users.

 

I built a canvas app for our field supports technicians and it works with 4 SharePoint lists:

  1. detailsList (~15000 records) -  ~2000 new records every month.
  2. devicesList (~800 records)
  3. departmentsList (~1000 records)
  4. customersList (few dozens)

On 1 of the screens, I want to present a filtered list, and add information from different lists (similar to join action).

i.e: filter the devicesList into a gallery, with 2 filters. Then, each item in the gallery should have a few fields from the detailsList and departmentsList.

I managed to do that, but when my devicesList filter returns more than ~30 items, the application is very slow and gets stuck.

I tried the next ideas but non of them solved the slowness of the app:

  • used addColumns to connect between the lists
  • set the columns I use as Index columns (in SharePoint list)
  • get the data to collection and work on the collections
  • use delegated filters 

I would really appreciate it if someone could give my ideas what needs to be changed in order for it to work w/o slowness or app stucks. 

 

my code for the Gallery.Items is:

 

 

 

 

SortByColumns(
 AddColumns(
 Filter(
 devicesList, /* I tried also with collection*/
 !devicesList.needsReplacement && !devicesList.replaced
 ),
 "lastVisitDate",
 Text(
 First(
 Filter(
 detailsList,
 customerID = DataCardValue_customerID.Text && deviceID = devicesList.deviceID
 )
 ).Visitdate,
 "mm.dd.yyyy"
 )
 ),
 "lastVisitDate",
 If(
 SortAscending,
 Descending,
 Ascending
 )
)

 

 

 

 

 example for the items I inserted to the gallery:

 

 

 

 

Concatenate(
 "department: ",
 First(
 Filter(
 depatrmentsList,
 Text(ID) = First(
 Filter(
 detailsList,
 customerID = DataCardValue_customerID.Text && deviceID = ThisItem.deviceID
 )
 ).departmentID
 )
 ).departmentID
)

 

 

 

 

 

  

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @IdanH 

    Your highest performance hits are going to come from using First(Filter !  

    When you use that, it is filtering ALL of the table and then using just one record.  These should all be replaced with LookUp.  LookUp finds the first match and returns it.

     

    Your next problem is going to be delegation. You might not be at the max limit of 2000 now, but you indicate the list will grow 2k per month.

    You are trying to use a Not (!) operator in your Filter.  This is not delegable!  You will need to revisit your list data structure and establish a way to have a delegable filter statement.  For example, if you are using Yes/No column for needsReplacement and replaced, then you need to re-examine that.  Consider using a text column like "ReplacementNeed" and "ReplaceStatus" (or a choice column with various values).  These will be delegable.

    Then you can delegate a formula like:

    Filter(devicesList,
     ReplacementNeed = "Not Needed" &&
     ReplaceStatus = "Not Replaced"
    )

    This will be delegable!

     

    So, your formula would become:

    SortByColumns(
     AddColumns(
     Filter(devicesList, 
     ReplacementNeed = "Not Needed" &&
     ReplaceStatus = "Not Replaced"
     ) As _device,
     "lastVisitDate",
     LookUp(detailsList, customerID = DataCardValue_customerID.Text && deviceID = _device.deviceID, VisitDate)
     ),
     "lastVisitDate",
     If(SortAscending, Descending, Ascending)
    )

    Avoid doing a Text conversion in the lastVisitDate as this will slow performance as well.  You can do the conversion elsewhere if needed.

     

    Also keep in mind that in your original formula, you are referencing entire tables. For example: devicesList.needsReplacement is an entire table with a single columns of needsReplacement.  This is not relevant for criteria.

     

    I hope this is helpful for you.

     

  • IdanH Profile Picture
    6 on at

    @RandyHayes  Thanks a lot for your fast reply and effort!

     

    I changed my gallery formula as you suggested and it improved the loading time (also no app freeze as before). However, it still takes a long time when the gallery results contains more than 50 items (more than 10 seconds).

    Another issue that I have with the LookUp is that the returned result is the first result (oldest result). I need the last result (the latest record that was inserted to the list), is that possible to get it with Lookup, or do I need to change it to Last function?

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @IdanH 

    You can try one other performance kick...change the formula to:

    With({_details: Sort(Filter(detailsList, customerID = DataCardValue_customerID.Text), Created, Descending)},
     SortByColumns(
     AddColumns(
     Filter(devicesList, 
     ReplacementNeed = "Not Needed" &&
     ReplaceStatus = "Not Replaced"
     ) As _device,
     "lastVisitDate",
     LookUp(_details, deviceID = _device.deviceID, VisitDate)
     ),
     "lastVisitDate",
     If(SortAscending, Descending, Ascending)
     )
    )

    This makes the LookUp "in memory" rather than to the datasource as the datasource is first gathered and filtered in the With variable.


    Also, the resulting table from the Filter is then sorted in reverse order, that should make the lookup find the first "newest" item.

     

  • IdanH Profile Picture
    6 on at

    @RandyHayes 

    Thanks a lot!

     

    I implemented your suggestion and it works ok.

    However, there is still some delay (~5 seconds) when the gallery contains more than 40-50 item and I am wondering if this is a network limitation or application limitation.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard