How to Prevent Initial Folder Query from Searching Subfolders

lager1001

Board Regular
Joined
May 17, 2019
Messages
88
I am querying a folder, a specific folder for files within it only. I am not interested in the files contained under the subfolders. The problem is that there are dozens of subfolders and hundreds of files in those folders. It is taking entirely too long for my folder query to go through these before I can apply the query filters to exclude them. Is there a way to initially have the query only point to the specific folder I am wanting and not any of its subfolders? I don't want the query to even look at those.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
maybe use Folder Path directly to selected folder, eg.
From Folder:
Source: C:\Users\user\Desktop\excel_solutions
and all sub folders

to
From Folder
Source: C:\Users\user\Desktop\excel_solutions\Excel\excel answers\PQTest\
 
Upvote 0
To be a bit more specific along Sandy's answer, as you build your query in Power Query, there is a column called Folder Path you see in your query once you have named the folder you want to search. Here is an example from one of my drives, where the Match Exception folder is the parent and I want to exclude the files in the archive folder underneath.

1592931415863.png


Just as you may filter file names in the Source.Name column to only take .xlsx or .csv files, you can use the same filter on the Folder Path column.
Add a command along the lines of the following to limit your files only to those items in the folder you want. In my case it is:

Table.SelectRows(YourPreviousStep, each ([Folder Path] = "S:\OFP\SCM Logistics Operations\Sources\Match Exception\"))
 
Upvote 0

Forum statistics

Threads
1,223,791
Messages
6,174,603
Members
452,574
Latest member
hang_and_bang

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top