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 / Cascading based Dropdo...
Power Apps
Unanswered

Cascading based Dropdowns and showing files in Document Library

(0) ShareShare
ReportReport
Posted on by 986

Hi everyone,

I have tried the following approach that is create a collection foldersCollection and filesCollection but the issue as soon as I add any new folders in the sub-levels it is also populated in the main level dropdown which should not happen.

Sidhant_02_0-1698301742917.png

The issue with this was if I add any folders in the sub-level then it was getting displayed in the dropdown1 (main-level). 

Sidhant_02_0-1698303017631.png

(As you can see in the above Picture, Level-1 is a folder that I have created in a sub-level Others so it should not appear in the main level and it should be present in that respective level like on selecting Others: as main level then in the 2nd drop-down Level-1 should be shown as an option)



So my requirement is:
I have created a Document Library named: TrialLibrary

Sidhant_02_1-1698301860364.png

 

Sidhant_02_2-1698301887380.png

 

Sidhant_02_3-1698301939918.png

 


Which has the following columns Name, Modified By, Created By (all these are System defined ). I have just added one choice column named Tags: (with the following choices - development, integration, security) which I will be associating with the files (from SharePoint side)

So on the main level : I have created 2 folders Training and Others
These folders may have sub-folders inside them or may not.
For now I have added a folder inside Others - Certifications, Exploration
In Certifications (Location: Others->Certifications) I have added 2 pdf files and similarly in Exploration (sub-folder inside Exploration) have added 3 docx files (assuming).

In Training folder:
I have not created any folders have only added files (Assumption : 4 pdf files)


So now in Power Apps the structure will be:
The main level drop-down will only show the drop-down in the main level not any other folders in the sub-level (like the Exploration or Certification folder that is created in the sub-level of Other folder). It should only show Training and Others as option.


Now if user selects Others (in the dropdown 1) then it should all the files if there are any in the gallery and if there are any folders in that level (here Others has 2 sub-folders only those name should come in the dropdown as values). Suppose if we select the 'Training' folder as the main level then the following dropdown (next drop-down) should not be visible as the Training folder does not have any sub-folders inside it, in this case just show the file details (if there are any) in the gallery.

So if user selects Others (main-level) then the next drop-down should be shown with only the folder names that are in that level (not others). So user can select the folders or user can skip that. There will be final drop-down that will be visible (irrespective there are files or folders in that respective levels) which will be used for filtering the records.

The sub-level folders may increase depending on that we need to show and filter records, so the program should adapt accordingly (that is the dropdowns), for now I am having only 2 levels (including the main level).
How to keep track of the Parent folders (in the sub-levels).

If anyone has any idea about this do share, will be helpful.

Regards,
Sidhant.

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,573 Most Valuable Professional on at

    The problem is that when you filter a document library on isFolder it is filtering it as a flat view rather than a hierarchy. You need to also filter based on the 'Folder Path' to figure out what level you are on.  This formula worked for me if the varPath variable was set to the 'Folder Path' of the parent folder. At the root its the name of the document library followed by '/'

     

    Filter(Documents, 'Folder path' = varPath && IsFolder = true)

     

     

     

  • Sidhant_02 Profile Picture
    986 on at

    Hi @Pstork1 
    Is it something like this:

    Sidhant_02_0-1698382721186.png


    So now I am able to get the folders only at the root level:

    Sidhant_02_1-1698382946473.png

     


    So now the next part was that the second drop down should be visible only if the sub-level has Folders inside it otherwise it should not be visible and only show all the files in the gallery (but the levels may increase later, that I have explained in the post)
    Currently the varPath is set to the root level:

    Sidhant_02_3-1698383545588.png

     

    How can we update this as we go in to the sub-levels?
    Also will the varPath be updated as when in we go into the sub-levels

    Sidhant_02_2-1698383474389.png

    This shows the same folders name as the varPath location is fixed.


    Regards,
    Sidhant.

  • Pstork1 Profile Picture
    69,573 Most Valuable Professional on at

    VarPath would be updated based on the Folder Path of the dropdown selection in the OnChange event. 

    Set(varPath, Concatenate(Self.Selected.'Full Path',"/"))

     

  • Sidhant_02 Profile Picture
    986 on at

    Hi @Pstork1 ,
    Now the path is getting updated as per the selection made in the Level-1 (root level) dropdown

    Sidhant_02_0-1698650483476.png

    So now I have also added a gallery to show the files and folders if there are any inside the Level-1 like for Others it should display the following:

    Sidhant_02_1-1698650581469.png

     

    So on the Level-2 dropdown (which is to be shown only when there are folders inside it otherwise don't show that here Others: has a folder so the second dropdown (level-2) will be shown whereas in Training there is no folder inside it so it is not visible)
     

    Filter(foldersCollection, 'Folder path' = varPath && IsFolder = true)

    So I used the above expression on dropdown - 5 (level-2) is this correct as there are no options that I am getting in this dropdown.

    So could you let me know how to proceed by showing files in the gallery and then filtering it down (based on the selections)

    On-Start of the app:

    Sidhant_02_2-1698650902358.png

     



    Regards,
    Sidhant.

  • Sidhant_02 Profile Picture
    986 on at

    Hi @Pstork1 ,
    The above expression that you have used should I use it in the On-start of the Application like this:

     

     

    Set(varPath, "TrialLibrary/");
    ClearCollect(foldersCollection,Filter(TrialLibrary, 'Folder path' = varPath && IsFolder=true));
    ClearCollect(filesCollection,Filter(TrialLibrary,IsFolder = false));

     

     

    Then I have used the same collection on the dropdown (main level) i.e. foldersCollection so here I am getting the folder names and On-Change of the drop-down 1 I have used the following expression

     

     

    Set(varPath, Concatenate(Self.Selected.'Full Path',"/"))

     

     

    This expression is updating the varPath based on the selection

    And also I have observed that initially the collection only has 2 records (i.e. 2 folder which are at the main level)

    Sidhant_02_0-1698821595467.png

     


    So even if update the varPath I guess it is not able to fetch any details as I have set the varPath initially with the root-level path, if this is the case how to resolve this?

    So on the next drop-down (Level-1/Sub-Folders) I did try this:

     

     

    Filter(foldersCollection, StartsWith('Folder path', varPath) && 'Folder path' <> varPath && IsFolder)
    
    //Also did try this:
    Filter(foldersCollection, 'Folder Path' = varPath && IsFolder)

     

     


    Both are not returning any values

    Sidhant_02_0-1698838872146.png

     


    Am I missing something?

    Once this is done I want to show the files details based on the level that we are in.
    Like in Training folder (Main level) it should all the three word file details and the second drop-down should not be visible as there are no sub-folders in it.

    Regards,
    Sidhant.

  • Sidhant_02 Profile Picture
    986 on at

    Hi @Pstork1 ,
    Just a small update so I made few changes in my Document library by enabling document content and added two columns to my SP list which are hiddenIsFolder and hiddenFolderPath (which has the full path: to avoid delegation) like this:

    Sidhant_02_0-1698906685726.pngSidhant_02_1-1698906703907.png

    And on the On-Start I am using a variable to indicate the root path of the library
    Set(varPath, "TrialLibrary/") and for each folder (sub-folders) I have defined the FolderPath for the hiddenIsFolderPath like:

    Sidhant_02_4-1698907425994.png

     



    On the main drop-down (Items property I am using the following)

     

    Filter(TrialLibrary,hiddenFolderPath = varPath)

     

    On-Change changing the path:

     

    Set(varPath, Concatenate(Self.Selected.'Full Path',"/"))
    //Set(varPath, Dropdown4.Selected.'Folder path' & Dropdown4.Selected.Name & "/") {Did't work}

     

     

    But the issue is: Now all the folder list and file names are getting populated in the main drop-down itself like:

    Sidhant_02_2-1698906997095.png

    Instead these values should be visible in the next drop-down (and the 2nd sub-level dropdown should only be visible if the level has any sub-folders inside it and accordingly the gallery should update and show the files )

    For the second drop-down I did try this:

    Sidhant_02_3-1698907156862.png

    But no results to show. In my case the main level should be fixed instead of changing (once a selection is made) and then the sub-dropdowns should be visible if there any sub-folders else no. The gallery should be updated as per the selection. Currently I am just pointing the gallery to the Document library.

    Regards,
    Sidhant.

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

#2
11manish Profile Picture

11manish 193

#3
Valantis Profile Picture

Valantis 138

Last 30 days Overall leaderboard