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 Automate / Filter Query to exclud...
Power Automate
Answered

Filter Query to exclude/include specific Folders

(0) ShareShare
ReportReport
Posted on by 122
In a Power Automate Flow, I need to exclude folders called "TEST 1" and "TEST 2".
My Filter Query looks like the screenshot attached which is working fine. When I tried to add the below criteria to exclude any folder "TEST 1", I wasn't successful. I even tried with 'New Designer' but none of their suggestions were accepted as well in the Flow.
 
Already Tried:
1. (FileLeafRef ne 'TEST 1')
2. not (startswith(Title, 'TEST 1')
3. not (endswith(Title, 'TEST 1')
4. not (substringof('TEST 1',Path)
5. not(folderPath ne '/TEST 1')
6. or startsWith(FSObjDisplayPath, '/TEST 1/')
 
Can anyone help me?
Thanks.
 
Shubhabrata_1-1711635256768.png

 

Categories:
I have the same question (0)
  • Verified answer
    creativeopinion Profile Picture
    10,502 Super User 2025 Season 2 on at

    @Shubhabrata The Get files (properties only) action will return all files and folders from the selected document library. You are already filtering out files only by using the FSObjType eq 0 query.

     

    However, you want to filter out files that are in specific folders and you'll need to use a Filter Array action to do that. Please note: I'm using the Classic Designer as the new designer is still buggy.

     

    Return File Count

    Whenever I use a Filter Query in a Get files (properties only) action, I always like to return the count of files returned in a Compose action. This is helpful when building a flow and can also be used to troubleshoot your flow.

    Insert a Compose action. Add an Expression. Use the length() function.

    creativeopinion_3-1711637171214.png

    Select the Dynamic content tab and insert the value dynamic content from the Get files (properties only) action into the length() function.

    creativeopinion_4-1711637194465.png

     

    Run a test. Review the outputs. Confirm the file count is what you are expecting. Remember this is the total file count based on your Filter Query.

    creativeopinion_5-1711637274037.png

     

    Filter Array

    Add a Filter Array action to your flow. Insert the value dynamic content from the Get files (properties only) action into the From field. In the first value field, insert the Folder path dynamic content form the Get files (properties only) action. Change the operator to does not contain. In the second value field, enter the folder name. You'll need to enter it exactly how it appears in your doc library (it's case sensitive).

     

    Insert one of the folder names first (for testing).

    creativeopinion_6-1711637298817.png

    Again, I would recommend adding a Compose action to store a count of the filtered files.

    creativeopinion_0-1711636933129.png

    In the length() function insert the body dynamic content from the Filter Array action.

     

    creativeopinion_1-1711636944042.png

    Run a test. Review the output of the Compose actions storing the file counts and compare. 

     

    creativeopinion_2-1711637050726.png

     

    Although it may look like the Filter Array action can only take a single condition—it can take multiple conditions when using the Advanced Editing Mode. Refer to this section of my YT Tutorial: Are you using the Microsoft Power Automate Filter Array Action wrong?

     

    I'll cover how to use multiple conditions in a Filter Array action. I'll also cover the following: 

     

    ✅ 3 Ways to Use the Filter Array Action

    ✅ How to use the Scope Action to Group Actions

    ✅ How to Check the Number of Items returned from a Filter Array Action

    ✅ How to Cross-Reference Data in Excel with a SharePoint List

    ✅ How the Filter Array Action Works

    ✅ How to Access the Dynamic Content from a Filter Array Action

    ✅ How to Filter Items by a Key

    ✅ How to Filter Items by Matching a Substring

    ✅ How to Use Multiple Conditions in a Filter Array Action

     

    Hope this helps!

    If I helped you solve your problem—please mark my post as a solution ✅.
    Consider giving me a 👍 if you liked my response!

    👉 Level up your Power Automate skills by checking out my tutorials on YouTube
    👉 Tips and Tricks on TikTok and Instagram

     

  • CU06081659-0 Profile Picture
    122 on at

    Hi @creativeopinion ,

     

    Your solution has worked successfully. I really thank you for such a descriptive help. I am not a Pro in PA and I really look forward to kind people like you who help us. I sincerely hope others who are looking for this solution can refer your answer.

    Have a great day ahead.

  • CU06081659-0 Profile Picture
    122 on at

    Hi @creativeopinion ,

     

    Can you help me with steps how I can get the files in a tabular format to see their Names, Creation Date Time and Folder? That'll help.

    Thanks.

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 Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard