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 / Gallery showing sharep...
Power Apps
Answered

Gallery showing sharepoint folders/files

(0) ShareShare
ReportReport
Posted on by 48 Season of Giving Solutions 2025
Hello, I have a gallery that shows folders and files from a sharepoint library. The gallery will show folder and files and if you click on the folder, the gallery will change the display to that folder. if you click on a file it will launch the file. Everything works fine. Code is below for my gallery.
 
As i add more files to the sharepoint, they don't show up in my gallery like the other ones do. I did notice the ID number of the newest file was 6371 which made me think this is not showing up because the delegation is over 2,000. If this is true i could use a littlehelp in getting around this id possible by altering my gallery filters.
 
The sharepoint site documents has about 12 different folders with many subfolders and files within. But how i have the gallery set up is to set varfolderpath as only of those folders. I checked the properties of that folder and there are 556 files and 140 folders.
 
SortByColumns(
    Filter(
        'Documents',
        'Folder path' = varFolderpath
    ),
    "{IsFolder}",
    SortOrder.Descending,
    "{Name}",
    SortOrder.Ascending
)
Categories:
I have the same question (0)
  • Suggested answer
    Pstork1 Profile Picture
    69,556 Most Valuable Professional on at
    I believe the problem is the SortByColumns() function.  That is only delegable if you are sorting based on simple data columns.  Columns like IsFolder are system columns and can't be used.  Check the Notes here: Connect to SharePoint from a canvas app - Power Apps | Microsoft Learn
     

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • Suggested answer
    WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
     
    As @Pstork1 has noted, both '{IsFolder}' and '{Name}' are not suppoted by Delegation, but neither is '{FolderPath}' in your FIlter. There is a solution to this (and I use something similar) - create a new Single Line of Text field in your Library (mine is called FolderName but you can call it whatever you want) and then use the Flow trigger When a file is created (properties only) and write the path into it as below
     
     
    You will need to "back fill" existing records, but this also can be done as below
     
    When you do this, also go into the Settings of Get files (properties only) and turn on Pagination - ensure the figure is greater than the number of files in the Library.
     
     
    Once you have done that, you can retreive the records with Delegation Support and then Sort them "locally" without Delegation limitations.
    With(
       {
          _Files:
          Filter(
             'Documents',
             FolderName = varFolderpath
          )
       },
       SortByColumns(
          _Files,
          "{IsFolder}",
          SortOrder.Descending,
          "{Name}",
          SortOrder.Ascending
       )
    )
     
    Please Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
  • Suggested answer
    MS.Ragavendar Profile Picture
    7,431 Super User 2026 Season 1 on at
     
    There is no other option than creating a custom column in sharepoint as @WarrenBelz suggested and updating the properties using the Power Automate. 
     
    Other way is create the data in chunks
     
    ClearCollect(
        colDocs,
        Filter('Documents', ID <= 2000)
    );
    Collect(
        colDocs,
        Filter('Documents', ID > 2000 && ID <= 4000)
    );
     
    Then bind the collection to the gallery.
    • Filter(colDocs,'Folder path' = varFolderpath),
    ✅If this helped, please Accept as Solution to help others ❤️ A Like is appreciated 🏷️ Tag @MS.Ragavendar for follow-ups.
  • Verified answer
    WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    ID is not Delegable for > greater than or < less than  - only = equals, so unfortunately that will not work. You can however (and I do regularly) create a shadow ID number field using the same principle I posted in the Flow (using the ID instead of the folder path) and then what you have would certainly be Delegable (or more correctly avoid Delegation restrictions as it is processed locally) using the added number field. If you have this number field and your Data Row Limit set to 2,000, you also can collect all records in the Library like this (see my blog on this)
    Clear(colDocs);
    With(
       {
          _Sets: 
          AddColumns(
             RenameColumns(
                Sequence(
                   RoundDown(
                      First(
                         Sort(
                            Documents,
                            ShadowID,
                            SortOrder.Descending
                         )
                      ).ShadowID / 2000,
                      0
                   ) + 1,
                   0,
                   2000
                ),
                Value,
                LowID
             ),
             HighID,
             LowID + 2000
          )
       },
       ForAll(
          _Sets As _MaxMin,
          Collect(
             colDocs,
             Filter(
                Documents,
                ShadowID > _MaxMin.LowID && ShadowID <= _MaxMin.HighID
             )
          )
       )
    )
     
  • CU10021407-0 Profile Picture
    48 Season of Giving Solutions 2025 on at
    I got the galleries to work via the collections method and the ShadowID.
    ClearCollect(    colDocs,    Filter('Documents', ID <= 2000));Collect(    colDocs,    Filter('Documents', ID > 2000 && ID <= 4000));
     
    Gallery = SortByColumns(Filter(colDocs,'Folder path' = varFolderpath), "{IsFolder}",SortOrder.Descending, "{Name}",SortOrder.Ascending)
     
    I got a flow to work to add to add the ShadowID whenever i add a file or folder.
     
    I created a flow as described above to update the existing items. looks like it updated all the folders but not the files
     
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    If you have between 2,000 and 4,000 you can also do it on the actual ID as per this blog of mine.
    With(
       {
          _Asc,
          Sort(
             Documents,
             ID
          ),
          _Desc,
          Sort(
             Documents,
             ID,
             SortOrder.Descending
          )
       },
       ClearCollect(
          ColDocs,
          _Asc,
          Filter(
             _Desc,
             !(ID in _Asc.ID)
          )
       )
    )
  • CU10021407-0 Profile Picture
    48 Season of Giving Solutions 2025 on at
    i actually have around 6,500 IDs in that sharepoint ..... my formula is actually:
     
    ClearCollect(colDocs,Filter('Documents', ShadowID <= 2000));
    Collect(colDocs,Filter('Documents', ShadowID > 2000 && ShadowID <= 4000));
    Collect(colDocs,Filter('Documents', ShadowID > 4001 && ShadowID <= 6000));
    Collect(colDocs,Filter('Documents', ShadowID > 6001 && ShadowID <= 8000));
    Collect(colDocs,Filter('Documents', ShadowID > 8001 && ShadowID <= 10000))
     
    That part is working fine now. It is just getting a flow to update all folders and files with the shadowID that are already existing in the sharepoint.
     
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    I posted the process for that in an earlier item
     
    When you do this, also go into the Settings of Get files (properties only) and turn on Pagination - ensure the figure is greater than the number of files in the Library.
     
     
    Please Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
  • CU10021407-0 Profile Picture
    48 Season of Giving Solutions 2025 on at
    Yes that was what i used. i was in there this morning and it appears that everything worked. I looked at the flow progress and it took about 25 minutes to complete. Guess i was checking before it completed and appears to be good now, thanks.
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    Hi @CU10021407-0,
    That is good.Yes, thousands of records will take a while using Apply to each. There is a quicker way of doing it but not worth the complication for a one-off exercise.

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard