Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Vinod_P
Helper I
Helper I

Unable to pull file names in folder

Hi ALL, 

 

I am using Power query to get file names in a folder .

 

Get data --> from file --> from folder 

 

Unfortunately I am having too many file subfiles which is cross 200,000 rows and unable to pull due to capacity issues .

 

Is there a way to enter the folder path and get the files names related to that folder alone either by using power qery or VBA 

 

Thanks 

1 ACCEPTED SOLUTION
slorin
Super User
Super User

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcraKiQlJzS1Qio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Folder" = _t]),
FolderContents = Table.AddColumn(Source, "Contents", each Folder.Contents([Folder])),
Expand = Table.ExpandTableColumn(FolderContents, "Contents", {"Name", "Extension", "Attributes", "Folder Path"}, {"Name", "Extension", "Attributes", "Folder Path"}),
Kind = Table.ExpandRecordColumn(Expand, "Attributes", {"Kind"}, {"Kind"}),
MySpecificFolder = Table.AddColumn(Kind, "Specific_Folder", each if [Name]="xxxx" and [Kind]="Folder"
then Folder.Contents([Folder Path]&[Name]) else null)
in
MySpecificFolder

Stéphane 

View solution in original post

3 REPLIES 3
slorin
Super User
Super User

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcraKiQlJzS1Qio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Folder" = _t]),
FolderContents = Table.AddColumn(Source, "Contents", each Folder.Contents([Folder])),
Expand = Table.ExpandTableColumn(FolderContents, "Contents", {"Name", "Extension", "Attributes", "Folder Path"}, {"Name", "Extension", "Attributes", "Folder Path"}),
Kind = Table.ExpandRecordColumn(Expand, "Attributes", {"Kind"}, {"Kind"}),
MySpecificFolder = Table.AddColumn(Kind, "Specific_Folder", each if [Name]="xxxx" and [Kind]="Folder"
then Folder.Contents([Folder Path]&[Name]) else null)
in
MySpecificFolder

Stéphane 

slorin
Super User
Super User

Hi,

 

Use Folder.Contents, not Folder.Files

 https://learn.microsoft.com/en-us/powerquery-m/folder-contents

 

Stéphane

Hi Stephane,

 

Thank you for the quick response. Thats the perfect solution and could you please help me little further. 

 

From the above I am getting list of folder names and from that will select one and need file names from the specific folder 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors