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 / How to view subfolders...
Power Apps
Answered

How to view subfolders and files within a folder in a document library?

(0) ShareShare
ReportReport
Posted on by 43

Hi all

 

I am a relatively new user to PowerApps and am trying to create an app that will allow users to navigate through a document library.  I have inserted a gallery into the canvas and connected it to the document library.  I then want to be able to select a folder and display the contents of it, in another gallery.

 

Any suggestions would be greatly appreciated.

 

Thank you in advance.

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hey @ell1990 

     

    To get the first level of folders, you can use the below expression on Gallery1:
    Gallery1 -> Items -> Filter(Documents, IsFolder = true && 'Folder path' = "Shared Documents/")
    Please check if "Shared Documents" is the correct root path in your case.

    To get the second level of folders, you can use the below expression on Gallery2:
    Gallery1 -> Items -> Filter(Documents, IsFolder = true && 'Folder path' = "Shared Documents/"&Gallery1.Selected.Name&"/")

    To get the third level of folders, you can use the below expression on Gallery3:
    Gallery1 -> Items -> Filter(Documents, IsFolder = true && 'Folder path' = "Shared Documents/"&Gallery1.Selected.Name&"/"&Gallery2.Selected.Name&"/")

     

    Hope this Helps!

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Verified answer
    v-siky-msft Profile Picture
    on at

    Hi @ell1990

     

    We can use Folder path to filter the gallery.

    1. Set the Items property of left gallery:  Filter(DOCS,'Folder path'="DOCS/") , DOCS is the name of SP document library.

    2. Set the Items property of right gallery: Filter(DOCS,'Folder path' = "DOCS/" & Gallery1.Selected.Name &"/" )

    Further steps, set the following steps to set the visible of the right gallery.

    1. Put UpdateContext({VarGal:false}) to OnVisible of screen

    2. Set OnSelect of right arrow to If(VarGal = false, UpdateContext({VarGal:true}),UpdateContext({VarGal:false}))

    3. Set Visible of the right property to VarGal

    StoG_2.gif

    Hope this can help.

    Best regards,

    Sik

     

  • Simmo2020 Profile Picture
    2 on at

    I am having seemingly random results with some folders in gallery one showing files in gallery2 but then some folders not showing any files in gallery2. Looking at Sharepoint there seems no difference between the folders (contents are similar, e.g. PDFs) and the folders were both created automatically by another process (the same process). Any ideas on anything I maybe missing?

  • leyburn19 Profile Picture
    2,157 on at

    I want to do something similar but I think the issue here is delegation,  None of the commands are delegable as I think the text is stored in multiple lines of text.  So you can only find a max of 2000 (depending on your settings)

  • Community Power Platform Member Profile Picture
    on at

    @v-siky-msft i had a question , if i wanted to build the same for lets say 3 Levels Example 
    Folder-> Folder->Folder_>Files.

    There might be a case where in some folders will not have subsequent folders but only files. will the folders then show files or not?

    How can I do that?

  • mdevaney Profile Picture
    29,989 Moderator on at

    @Anonymous

    I agree, the accepted solution does not work for more than 2-levels.  I have a solution that can navigate all levels of folders, subfolders and files.

    Check out this link for a full tutorial on how to make the app in my screenshot:
    https://www.matthewdevaney.com/power-apps-navigating-folders-subfolders-in-a-sharepoint-document-library/

    powerapps-doclibrarybrowse-30.gif


    As a very short summary, what @ell1990 should do is filter the Items property of the gallery like this.

     

    Filter(
     'Customer Files',
     'Folder path' = varFolderPathCurrent
    )

     



    Then use this code in the OnSelect property of the gallery to browse to the next level of the folder or open up a file depending on what the user clicks.

     

     

    If(
     // checks whether the gallery item is a folder or file
     ThisItem.IsFolder,
    
     // get the current location for the selected folder
     Set(
     varFolderPathCurrent,
     ThisItem.'Full Path' & "/"
     ),
    
     // open the file a new browser tab
     Launch(
     ThisItem.'Link to item',
     Blank(),
     LaunchTarget.New
     )
    )

     



    We can also build a way to go back to a previous folder in the file tree.  That's explained in my article as well.

     

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard